Problem use VB6.0 connect via ODBC to MySQL
am 27.01.2005 04:16:11 von SalaPao Soil
--0-1052125843-1106795771=:56790
Content-Type: text/plain; charset=us-ascii
Hi,
I have problem with use VB6.0 connect to MySQL4.1.9(win32);i have question this
1.How i can define connectionstring? I try to connect via DSN which i create form System DSN by use My ODBC 3.51 another i try connect via provider but Error Msgbox alert me too?
2.Parameter uid(Userid) and pwd(password), I need to define value? Like uid=sa and pwd=pwd, need?
3.In step rs.Open ....., What i wrong?? It s appear Run-Time Error 3709: Operation is not allowed on object referencing a closed or invalid connection
4.Please,Explain me about cn, adOpenKeyset, adLockOptimistic, adCmdText and How to use it?
Thanks your
Team
Option Explicit
Private cn As ADODB.Connection
Private rs As ADODB.Recordset
Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.Open "DSN=dsn4mysql;uid=;pwd=;database=DB1" dsn4mysql i create form System DSN with install MyODBC 3.51 too.
Another way i can use like this or not? cn.ConnectionString = "driver={MySQL};" & _
"server=127.0.0.1;uid=;pwd=;database=DB1"
Set rs = New ADODB.Recordset
rs.Open "select name,mo from Table1", cn, adOpenKeyset, adLockOptimistic, adCmdText
end sub
---------------------------------
Do you Yahoo!?
Yahoo! Search presents - Jib Jab's 'Second Term'
--0-1052125843-1106795771=:56790--
RE: Problem use VB6.0 connect via ODBC to MySQL
am 27.01.2005 17:12:53 von Artem Koltsov
Hi,
Try this one:
Sub test()
=20 Dim con As New ADODB.Connection, rs As ADODB.Recordset =20
=20 con.Open "DRIVER=3D{MySQL ODBC 3.51 Driver};DESC=3D;DB=3Ddbname;SER=
VER=3Dserver_ip;UID=3Dusername;PASSWORD=3Dpassword;PORT=3D33 06;SOCKET=3D;=
OPTION=3D;STMT=3D;"
=20 Set rs =3D con.Execute("SELECT now()")
=20 Debug.Print "Time: "; rs.Fields(0).Value
=20 rs.Close
=20 con.Close
=20 Set rs =3D Nothing
End Sub
Also you can read about adOpenKeyset, adLockOptimistic, and adCmdText on =
Microsoft web site (MSDN online).
> -----Original Message-----
> From: SalaPao Soil [mailto:safesoil@yahoo.com]
> Sent: Wednesday, January 26, 2005 10:16 PM
> To: myodbc@lists.mysql.com
> Subject: Problem use VB6.0 connect via ODBC to MySQL
>=20
>=20
>=20
> Hi,
>=20
> I have problem with use VB6.0 connect to=20
> MySQL4.1.9(win32);i have question this
>=20
> 1.How i can define connectionstring? I try to=20
> connect via DSN which i create form System DSN by use My ODBC=20
> 3.51 another i try connect via provider but Error Msgbox=20
> alert me too?
>=20
> 2.Parameter uid(Userid) and pwd(password), I=20
> need to define value? Like uid=3Dsa and pwd=3Dpwd, need?
>=20
> 3.In step " rs.Open .....", What i wrong?? It=20
> 's appear "Run-Time Error '3709': Operation is not allowed on=20
> object referencing a closed or invalid connection"
>=20
> 4.Please,Explain me about "cn, adOpenKeyset,=20
> adLockOptimistic, adCmdText " and How to use it?
>=20
> Thanks your=20
>=20
> Team
>=20
> =20
>=20
> Option Explicit
>=20
> Private cn As ADODB.Connection=20
>=20
> Private rs As ADODB.Recordset=20
>=20
> Private Sub Form_Load()
>=20
> Set cn =3D New ADODB.Connection=20
>=20
> cn.Open "DSN=3Ddsn4mysql;uid=3D;pwd=3D;database=3DDB1" 'dsn4mysql=20
> i create form System DSN with install MyODBC 3.51 too.
>=20
> 'Another way i can use like this or not?=20
> cn.ConnectionString =3D "driver=3D{MySQL};" & _=20
>=20
> "server=3D127.0.0.1;uid=3D;pwd=3D;database=3DDB1"
>=20
> Set rs =3D New ADODB.Recordset=20
>=20
> rs.Open "select name,mo from Table1", cn, adOpenKeyset,=20
> adLockOptimistic, adCmdText =20
>=20
> end sub
>=20
> =20
>=20
>=20
> =09
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Search presents - Jib Jab's 'Second Term'
>=20
=A0
Attention:
Any views expressed in this message are those of the individual sender, e=
xcept where the message states otherwise and the sender is authorized to =
state them to be the views of any such entity. The information contained =
in this message and or attachments is intended only for the person or ent=
ity to which it is addressed and may contain confidential and/or privileg=
ed material. If you received this in error, please contact the sender an=
d delete the material from any system and destroy any copies.
--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=3Dgcdmo-myodbc@m.gmane.o rg