tgf-47
Member
- Joined
- Feb 16, 2010
- Messages
- 15
- Programming Experience
- Beginner
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?
using vb.net 2008
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?
using vb.net 2008