I'm trying to connect to a mySql database using VB 2008.
I have created a test database called 'bank'.
I have created an dsn file called mySQLODBC.
The test connection for the ODBC is successful.
my problem is in connecting and reading the data from VB
I have input the following into a console project.
The Database is bank, the dsn file is mySqlODBC, the Table is Person adn I'm trying to read the fname field.
I'll appreciate all help.
Thanks
H
I have created a test database called 'bank'.
I have created an dsn file called mySQLODBC.
The test connection for the ODBC is successful.
my problem is in connecting and reading the data from VB
I have input the following into a console project.
VB.NET:
Imports System
Imports System.Data
Imports System.Data.Odbc
Module OdbcProvider
Sub Main()
Dim connString As String = "dsn=c:\\Documents and settings\Hugh\My Documents\SQL\mySqlODBC.dsn"
Dim sql As String = "Select fname from Person"
Dim reader As OdbcDataReader = Nothing
Try
Dim conn As New OdbcConnection(connString)
conn.Open()
Dim cmd As New OdbcCommand(sql, conn)
Console.WriteLine("this shows" & "ODBC Provider")
reader = cmd.ExecuteReader()
Console.ReadLine()
Catch e As exception
Console.writeline("Error: ", e)
Finally
Reader.close()
End Try
End Sub
End Module
The Database is bank, the dsn file is mySqlODBC, the Table is Person adn I'm trying to read the fname field.
I'll appreciate all help.
Thanks
H