I'm trying another method to connect mysql and vb.net. I didn't have any difficulties connecting mysql and vb.net when using mysql net connector. And I also used the same codes. I just replaced the ones that needed to be replaced with odbc.
Imports System.Data.Odbc
Public Class globalclass
Private cn As New OdbcConnection("DSN=korosu")
Dim cmd As Odbc.OdbcCommand
Public name As String
Public age As String
Public Sub New()
cn.Open()
cmd = New Odbc.OdbcCommand("SELECT * FROM test")
End Sub
Public Sub adds()
cmd.CommandText = "INSERT INTO test(name, age) VALUES('" + name + "','" + age + "')"
cmd.ExecuteNonQuery()
End Sub
What do I need to do to fix this? I always get the runtime error and its highlighting the cmd.ExecuteNonQuery. And says that the connection has not been properly initialized.Please help