Error in VB.net with MYSql

Hi all,

I do not have to much experience in VB.net. I am doing small application to practice.

In this case I am creating a VB application conneting to a MYSQL Database.

The problem I have is when I try to make a new register into the DDBB, I recieve a syntaxis error.

INSERT INTO Libros(Titulo,Desc) VALUES ('" & Titulo_text.Text & "', '" & Desc_text.Text & "')

However if I use the command into mysql server it works fine.

INSERT INTO Libros(Title,Desc) VALUES ()

Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
-----------------

If sConnection.State = ConnectionState.Closed Then
sConnection.ConnectionString = "SERVER = my server; USERID = joserodriguezan; PASSWORD = Aberystwyth; DATABASE = Bibloteca;"
sConnection.Open()
End If
Try
strSQL = "INSERT INTO Libros(Title,Desc) VALUES ('" & Title_text.Text & "', '" & Desc_text.Text & "')"
Dim da As New MySqlDataAdapter(strSQL, sConnection)
da.Fill(dset)
Catch ex As Exception
MessageBox.Show("Error")
End Try

Tittle_text.Text = ""
Desc_text.Text = ""
Class_combo.Text = ""
Date_text.Text = ""
Pres_text.Text = ""
Who_text.Text = ""
Title_text.Focus()
list()
End Sub
-----------------------

Any knows how to resolve this problem?
Thank you.

Comments

  • Hello,

    Please let me know the exact error message are you getting

    Thanks
    [URL="http://www.traklive.com"]Bug Tracking[/URL] -
    [URL="http://www.livetecs.com"]Web Timesheet[/URL]
    [URL="http://www.livetecs.com"]Time Tracking Software[/URL]
  • Thank you Livetechs,

    I resolve the problem by myself.
    The problem was a syntaxis error in mysql command.

    I modified the sql commmand adding ` single quote in the command.
    strSQL = "INSERT INTO `Libros`(`Title`,`Desc`) VALUES ('" & Title_text.Text & "', '" & Desc_text.Text & "')"

    Thank you for you help.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories