Visual Basic.NET - Agregar registor en formalario con BD MySql

 
Vista:
Imágen de perfil de jose
Val: 42
Ha aumentado su posición en 2 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Agregar registor en formalario con BD MySql

Publicado por jose (33 intervenciones) el 31/03/2013 10:16:44
Hola a todos,

Aunque llevo más de un año con VB.net, poco a poco voy aprendiendo.

Estoy haciendo pruebas con MySQL.

He creado un formulario en donde no me funciona el insertar registro.

Sin embargo en el servidor de MySQL funciona correctamente.


Private Sub Guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Guardar.Click

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

Titulo_text.Text = ""
Desc_text.Text = ""
Clase_combo.Text = ""
Fecha_text.Text = ""
Pres_text.Text = ""
Quien_text.Text = ""
Titulo_text.Focus()
MsgBox("El registro se añadio correctamente")
list()
End Sub

Al darle al boton me sale un error de sintasix.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder