Re: mysql conected to vb.net
i think this wrong in your delete code :
vb Code:
Dim Sql As String = "DELETE FROM asignatura Where ID_ASIGNATURA= 'id.Text.Trim'"
should be:
vb Code:
Dim Sql As String = "DELETE FROM asignatura Where ID_ASIGNATURA= '" & id.Text.Trim & "'"
id.Text.Trim is textbox control, doesn't it ?
Re: mysql conected to vb.net
id is the text box.... id.text would be the text contents of the text box... id.text.trim would be a call to the Trim function of a string object that should trim all white space from the front and back of the string.
-tg
Re: mysql conected to vb.net
l should say first Thanks you .
yes , l missed the ( & &) , but in the DB ID_ASIGNATURA is Integer type that is why l l dont put "" ""
now l can insert , add but l cant delete
Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' CLAUSULA SQL ELIMINAR REGISTRO
Try
CONECTAR()
Dim Sql As String = "DELETE FROM asignatura Where ID_ASIGNATURA= " & id.Text & ""
cmd = New MySqlCommand(Sql, con)
Dim myCommand As New MySqlCommand(Sql)
myCommand.ExecuteNonQuery()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
Public Function Sql() As Object
Throw New NotImplementedException
End Function
End Class
something wrong in this , l just dont know what is it ?
Re: mysql conected to vb.net
I'm not sure why you have that public function there...that seems like a bad idea. Regardless, what exactly happens?
Re: mysql conected to vb.net
l cant delete from the data base that is all , l want to be able to delete data based on ID . as the code says .
should l delete that publci funciton ?
Re: mysql conected to vb.net
finally got the reason why :
here is final code : l had to excute the funciton ExecuteNonQuery() on the calling of the class MySqlCommand after passing to it sql and con arguments .
Code:
CONECTAR()
Dim Sql As String = "DELETE FROM asignatura Where ID_ASIGNATURA = " & id.Text & ""
cmd = New MySqlCommand
cmd(Sql, con).ExecuteNonQuery()
MsgBox("El Registro a sido Eliinado")
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try