百度了好久,代码大多都很类似,下面是代码片段,但是就是不行。。。
DataSet dsDZJC = local.retDZJC_xzsp("AHKYQ", "", "", "", "");//webservice端口获取的dataset数据集 string strSQL = "select * from FLOWCTRL "; string connstring = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; OracleConnection conn = new OracleConnection(connstring); OracleCommand cmd = new OracleCommand(strSQL, conn); conn.Open(); OracleDataAdapter dataAdapter = new OracleDataAdapter(strSQL, conn); DataSet ds = new DataSet(); dataAdapter.Fill(ds, "myTable"); dataAdapter.FillSchema(ds, SchemaType.Mapped); OracleCommandBuilder cmdBuilder = new OracleCommandBuilder(dataAdapter); //设置主键 ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns[0] }; cmdBuilder.DataAdapter = dataAdapter; dataAdapter.InsertCommand = cmdBuilder.GetInsertCommand(); dataAdapter.DeleteCommand = cmdBuilder.GetDeleteCommand(); dataAdapter.UpdateCommand = cmdBuilder.GetUpdateCommand(); ds = dsDZJC; dataAdapter.Update(ds, "myTable"); ds.Tables["myTable"].AcceptChanges();
现在有两个问题:
1、连接Oracle数据库时出问题: