Insert into table
Posted by: Amalia Stan
Date: August 13, 2009 02:18AM

Hi,
A have a problem in trying to insert data in mysql table from vb.net.
This is my code but it does nothig:
Dim myConnectionString As String
myConnectionString = "server=192.168.0.51;" _
& "uid=root;" _
& "pwd=greed;" _
& "database=registru;"

Try
Dim conn As New MySql.Data.MySqlClient.MySqlConnection(myConnectionString)
conn.Open()
MessageBox.Show("Connection Opened Successfully")
Dim sql As String
sql = "INSERT INTO registru_i_o (Nr_inregistrare,Data_Intrare,Unitatea_emitenta,Continut,Responsabil,Data_iesire,Unitatea_rec) VALUES(" + TextBox1.Text + "," + DateTimePicker1.Value + "," + TextBox2.Text + "," + TextBox3.Text + "," + TextBox4.Text + "," + DateTimePicker2.Value + "," + TextBox5.Text + ")"
MessageBox.Show(sql)
Dim adapter As New MySqlDataAdapter
adapter.InsertCommand = New MySqlCommand(sql, conn)
adapter.InsertCommand.ExecuteNonQuery()
Catch ex As MySql.Data.MySqlClient.MySqlException
Select Case ex.Number
Case 0
MessageBox.Show("Cannot connect to server. Contact administrator")
Case 1045
MessageBox.Show("Invalid username/password, please try again")
End Select
End Try


please help me :).

Options: ReplyQuote


Subject
Written By
Posted
Insert into table
August 13, 2009 02:18AM
September 06, 2009 10:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.