azu donald

azu donald

  • NA
  • 1
  • 0

need help iserting into mysql from vb.net

Oct 27 2009 11:52 AM
pls anytime i run this code i get a syntax error. i need someone to tell me what i'm doing wrong and point me in he right direction asap. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim command As New MySqlClient.MySqlCommand conn = New MySqlConnection conn.ConnectionString = "server=localhost;" _ & "database=cargomate;" _ & "userid=root;" _ & "password=admin" Try conn.Open() Catch myerror As MySqlException MsgBox("Error connecting to database") End Try cargo.transid = TextBox1.Text cargo.describe = TextBox2.Text cargo.num = TextBox3.Text cargo.weigh = TextBox4.Text cargo.ag = ComboBox1.SelectedItem cargo.air = ComboBox2.SelectedItem cargo.destiny = ComboBox3.SelectedItem Label9.Text = cargo.calprice Try sql = "insert into invoice(transactionid, description, quantity, weight, agent, airline, destination, price, timestamp) values =(' " & TextBox1.Text & " ', ' " & TextBox2.Text & " ', ' " & TextBox3.Text & " ', ' " & TextBox4.Text & " ', ' " & ComboBox1.SelectedItem & " ', ' " & ComboBox2.SelectedItem & " ', ' " & ComboBox3.SelectedItem & " ' ' " & Label9.Text & " 'now());" command.Connection = conn command.CommandText = sql command.ExecuteNonQuery() Catch myerror As MySqlException MsgBox("operation not sucessfull") End Try End Sub