|
-
May 5th, 2010, 05:31 AM
#1
Thread Starter
Addicted Member
[RESOLVED] How to hardcode a connection to a MySQL DB and code a Datatable? I need help
My system use to run on from a access database. Now I created the database on a MySQL server.
I can connect to it using the connection wizzard, but I prefer using my old methods as shown below.
I used this to connect to my access database:
Private Function MYDATA() As DataTable
Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=wc.mdb;Persist Security Info=False"
Dim cmd As String = "SELECT * FROM st_trans"
Dim ad As New System.Data.OleDb.OleDbDataAdapter(cmd, conn)
Dim topics As New DataSet()
ad.GetFillParameters()
ad.Fill(topics)
MYDATA = topics.Tables(0)
End Function
I'm not very clued up on MySQL, but I tried to change the Function as follows:
Private Function MYDATA() As DataTable
Dim conn As String = "Server=192.168.0.36;Port=3306;Database=wc;Uid=root;Pwd=ssf2;"
Dim cmd As String = "SELECT * FROM st_trans"
Dim ad As New System.Data.SqlClient.SqlDataAdapter(cmd, conn)
Dim topics As New DataSet()
ad.GetFillParameters()
ad.Fill(topics)
MYDATA = topics.Tables(0)
End Function
This doesn't work. When it gets to "ad.Fill(topics)", it bombs out.
This tells me I'm going all wrong here.
Does anyone know how to hardcode a connection and selection like I use to do with access, but only in MySQL?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|