none
OracleCommand里执行alter语句 RRS feed

  • 问题

  •  string ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.002)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORACLE)));Persist Security Info=True;User ID=STC;pwd=password";
    
     using (OracleConnection connection = new OracleConnection(ConnectionString))
     {
    
     connection.Open(); 
     OracleCommand command = connection.CreateCommand();
     OracleTransaction transaction;
     // Start a local transaction
     transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);
    
     // Assign transaction object for a pending local transaction
     command.Transaction = transaction;
    
     try
     {  
      command.CommandText = "alter session set NLS_DATE_LANGUAGE = 'AMERICAN'";
    
      command.ExecuteNonQuery();
    
      transaction.Commit(); 
    
     }
    
     catch (Exception ex)
     {
    
      transaction.Rollback();
    
     }
    
     }

    在C#中OracleCommand执行alter对Oracle数据库进行操作时(Oracle账户是系统管理员),程序就死了

    如果要在Insert数据前,执行alter session set NLS_DATE_LANGUAGE = 'AMERICAN'这条语句,应该怎么做?

    而且不执行这一条,insert数据时,日期类型(2010-12-21 10:20:10 AM)会报错,我是中文系统,日期改为2010-12-21 10:20:10 上午就可以插入了。我想执行alter方法后,再批量插入数据。

    通过OleDbConnection么?

    2010年12月21日 14:10

答案