none
how can i insert combobox value into a ms access database table using vb.net?? RRS feed

  • Question

  • This is the way I've tried. Please tell me what is the error with this code

     

    Dim con As OleDbConnection
            Dim com As OleDbCommand

            con = New OleDbConnection("provider= microsoft.jet.OLEDB.4.0;data source=D:\lorry services.mdb;")

            com = New OleDbCommand("INSERT INTO lorry values(@assetid,@ServiceDate,@service,@servicedescription,@debet,@credit,@totalexpenses,@totalincome)", con)

            con.Open()

            com.Parameters.AddWithValue("@assetid", ComboBox1.Text.Length)
            com.Parameters.AddWithValue("@servicedate", DateTimePicker1.DataBindings)
            com.Parameters.AddWithValue("@service", ComboBox2.Text.Length)
            com.Parameters.AddWithValue("@servicedescription", TextBox1.Text)
            com.Parameters.AddWithValue("@debet", TextBox2.Text)
            com.Parameters.AddWithValue("@credit", TextBox3.Text)
            com.Parameters.AddWithValue("@totalexpenses", TextBox4.Text)
            com.Parameters.AddWithValue("@totalincome", TextBox5.Text)
            com.ExecuteNonQuery()
            MsgBox("Record Added")

            con.Close()

    • Moved by SamAgain Tuesday, July 6, 2010 3:14 AM better fit (From:Common Language Runtime)
    Monday, July 5, 2010 4:12 PM

Answers