日期:2014-05-18  浏览次数:20519 次

高分求助:往oracle数据库提交数据的问题
protected   void   Button2_Click(object   sender,   EventArgs   e)
        {
                OracleConnection   conn   =   new   OracleConnection( "Data   Source=caora;User   ID=gufei;Password=gufei; ");
                //在此构造你所需的Sql语句。      
                String   strSql   = "Insert   into   GUFEI.PRODUCTION(PRODUCTNO)   values( ' "   +   TextBox1.Text   +   " ') "
                + "Insert   into   GUFEI.PRODUCTION(PRODCODE)   values( ' "   +   TextBox2.Text   +   " ') "
                +   "Insert   into   GUFEI.PRODUCTION(PUNIT)   values( ' "   +   TextBox3.Text   +   " ') "
                +   "Insert   into   GUFEI.PRODUCTION(PRODNAME)   values( ' "   +   TextBox4.Text   +   " ') "
                +   "Insert   into   GUFEI.PRODUCTION(PQUANTITY)   values( ' "   +   TextBox5.Text   +   " ') ";
                OracleCommand   cmd   =   new   OracleCommand(strSql,   conn);
                cmd.Connection.Open();
                //通过SqlCommand对象执行Sql命令语句即可。      
                cmd.ExecuteNonQuery();
                //cmd.Connection.Close();
这是我提交textbox的按纽,报错:ORA-00933:   SQL   命令未正确结束

------解决方案--------------------
分号;


分号;

insert into table1 Col1 values ( '1 '); insert into table1 Col1 values ( '2 ');

貌似应该这样啊 好像是
------解决方案--------------------
每个insert语句后加分号

String strSql = "Insert into GUFEI.PRODUCTION(PRODUCTNO) values( ' " + TextBox1.Text + " '); "
+ "Insert into GUFEI.PRODUCTION(PRODCODE) values( ' " + TextBox2.Text + " '); "
+ "Insert into GUFEI.PRODUCTION(PUNIT) values( ' " + TextBox3.Text + " '); "
+ "Insert into GUFEI.PRODUCTION(PRODNAME) values( ' " + TextBox4.Text + " '); "
+ "Insert into GUFEI.PRODUCTION(PQUANTITY) values( ' " + TextBox5.Text + " '); ";