mySQL and VB.net

apoc

New member
Joined
Feb 12, 2005
Messages
1
Programming Experience
1-3
Does anyone have any suggestions on how I could connect to an mySQL database using VB.
 

ryodoan

Well-known member
Joined
Jul 16, 2004
Messages
65
Location
Ohio
Programming Experience
3-5
VB.NET:
 Dim myConnection As String = "UID=USERNAME;PWD=password;DATABASE=dbname;WSID=COMPUTER-7A8D3E;APP=Microsoft Data Access Components;SERVER=COMPUTER-7A8D3E"
Private myDBConn As SqlClient.SqlConnection
myDBConn = New SqlClient.SqlConnection(myConnection)
The above is how you would form a connection a database. The myConnection string is can be generated useing "Data Sources (ODBC)" under adminstrative tools in the control panel.

You want the "File DSN" tab, and click add, follow the steps, and when you are done, open the final file in notepad, copy and paste the string, trim it down to what you see above, and you should be good.

To get information out of the database:

VB.NET:
'Open a connection
myDBConn.Open()
Dim _dt As New DataTable

'Create a command to a stored procedure and add parameters
Dim _cmdInfo As New SqlClient.SqlCommand(StoredProcedureName, myDBConn)
With _cmdInfo
			.Parameters.Add(Parameter)
			.CommandType = CommandType.StoredProcedure
End With
'Create the dataadapter using our command
Dim _da As New SqlClient.SqlDataAdapter(_cmdStuInfo)
 _da.SelectCommand = _cmdStuInfo

'Fill a table
_da.Fill(_dt)
myDBConn.Close()
 

dha03117761

New member
Joined
Mar 20, 2005
Messages
1
Programming Experience
Beginner
Hi I'd like to knoiw to create the DSN and what is it. Can I connect to the Database without using DSN
 

callraheel

Well-known member
Joined
Dec 12, 2004
Messages
65
Location
London,UK
Programming Experience
1-3
Hey
I have an alternative. You may see that when you try to do it with .NET connector or ODBC then it take much time to fetch or insert data. For quick data transection use the following :
ByteFX MySQL Data Transector.
I dont remember URL yet but i have its setup file. So if u need that send me a message with your email. I will send you manually.
Regards
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
The ByteFX Data Connector was purchased by MySQL, and is now offered in the URL I posted above. The current version is much more stable, and they are planning a future version which will have visual deesigners.
 
Top Bottom