Click here to Skip to main content
15,886,593 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim cb As New OleDb.OleDbCommandBuilder(da)
VB
ds.Tables("Transport2003").Rows(inc).Item(1) = TxtDate.Text
       ds.Tables("Transport2003").Rows(inc).Item(2) = TxtFreightSlipNo.Text
       ds.Tables("Transport2003").Rows(inc).Item(3) = ComboBox1.SelectedValue
       ds.Tables("Transport2003").Rows(inc).Item(4) = TxtTo.Text
       ds.Tables("Transport2003").Rows(inc).Item(5) = TxtRatePerTon.Text
       ds.Tables("Transport2003").Rows(inc).Item(6) = TxtRatePerTrip.Text
       ds.Tables("Transport2003").Rows(inc).Item(7) = ComboBox2.SelectedValue.ToString
       ds.Tables("Transport2003").Rows(inc).Item(8) = ComboBox3.SelectedValue.ToString
       ds.Tables("Transport2003").Rows(inc).Item(9) = TxtTon.Text
       ds.Tables("Transport2003").Rows(inc).Item(10) = ComboBox4.SelectedValue.ToString
       ds.Tables("Transport2003").Rows(inc).Item(11) = TxtExtra.Text
       ds.Tables("Transport2003").Rows(inc).Item(12) = TxtTrips.Text
       ds.Tables("Transport2003").Rows(inc).Item(13) = TxtActualWeight.Text
       ds.Tables("Transport2003").Rows(inc).Item(14) = TxtBillWeight.Text
       ds.Tables("Transport2003").Rows(inc).Item(15) = TxtAmount.Text


da.Update(ds, "Transport2003")'getting error here-Sytax error

when i select value from combobox1.selectedValue then automatically value comes from TxtTo.Text and
SQL
 when Update by changing selected value from combobox1.selectedvalue
i got error syntax error in da.Update ("")

follwing procedure of combobox1:

VB
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Try
            con.Open()


            sql = "select * from Rates where From ='" + ComboBox1.Text + "'"
            sqlcmd = New OleDb.OleDbCommand(sql, con)
            reader = sqlcmd.ExecuteReader

            While reader.Read

                TxtTo.Text = reader.Item("To")
                TxtRatePerTon.Text = reader.Item("RatesPerTon")
                TxtRatePerTrip.Text = reader.Item("RatesPerTrip")
            End While
            reader.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
Posted
Updated 14-Mar-15 21:15pm
v4
Comments
What is that error message?

1 solution

SQL
select * from Rates where From =


In general, that is a bad idea to name a column with a reserved word of the sql language (from).

In this case, you should enclose your column name between [ ] and/or qualify it with it's full qualifier:
SQL
select * from Rates where [Rates].[From] =


Moreover, it is a terrible practice to construct a sql query by concatenating strings from user input like you are doing ; it leaves your code opened to SQL injection attacks. Better use parameterized queries which will ensure that nobody can act on your database in a way you would not have wanted in the first place. There are plenty of examples on this site's forums of parameterized queries, you just have to do a quick search for these words.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900