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.
 
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()
 
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
 
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.
 
Back
Top