数据没有通过asp.net网页插入到oracle数据库中

时间:2012-01-21 11:57:33

标签: asp.net oracle c#-4.0

  

string ConnectionString =“Provider = MSDAORA; Data Source = orcl; Persist Security Info = True; User ID = web; password = web”;

        OleDbConnection MyOleDbConnection = new OleDbConnection(ConnectionString);
        OleDbCommand MyOleDbCommand = MyOleDbConnection.CreateCommand();
        MyOleDbCommand.CommandText = "insert into SL_Trans_Booking_hdr (Distributor_name, Booking_date) values (@customer, @date)";

        MyOleDbCommand.Parameters.AddWithValue("@customer", TextBox1.Text);
        MyOleDbCommand.Parameters.AddWithValue("@date", TextBox2.Text);
        try
        {
            MyOleDbConnection.Open();
            int a = MyOleDbCommand.ExecuteNonQuery();
            if (a > 0)
            {
                Response.Write("Go Ahead");
            }
            else
            {
                Response.Write("Try again");
            }
        }
        catch (Exception err)
        {

            Console.WriteLine("{0}", err);

        } 
        finally
        {
            MyOleDbConnection.Close(); 
        }

0 个答案:

没有答案