Hi friend i use this code to connect via vb6 a mysql database in local.

Is possible to connect other pc with the same code on the dsn on original pc where reside the dsn?

Tks for all and sorry for my bad english i'm italian.

Sub uno()

Dim conn As ADODB.Connection, rec As ADODB.Recordset

Set conn = New ADODB.Connection

Set rec = New ADODB.Recordset

conn.Open "Dsn=test"

rec.Open ("select * from staff"), conn, adOpenStatic, adLockReadOnly

Debug.Print rec.Fields(0)

Debug.Print rec.Fields(1)

rec.Close

conn.Close

Set conn = Nothing

End Sub

note:

i know the ip od pc where is the dsn


Hi there,
Try the followin to solve the problem..Let me know...
You can adopt this plan.
under control panel, ODBC, create a new DSN (data service Name) point to the access database, enter the user id and password.
and save it after naming it say Test.

use this code in the vb project;

Option Explicit
Dim conn As ADODB.Connection, rec As ADODB.Recordset
'under control panel_odbc create a DSn called Jinnie_test. point it to mdb file and enter user id and password
Private Sub Command1_Click()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Dsn=test" ' test is the DSN Name.
rec.Open ("select * from testable2"), conn, adOpenStatic, adLockReadOnly
Text1 = rec.Fields(0)
Text2 = rec.Fields(1)
rec.Close
conn.Close
Set conn = Nothing
End Sub


Take Care..Buddy..

Hi friend i use this code to connect via vb6 a mysql database in local.

Is possible to connect other pc with the same code on the dsn on original pc where reside the dsn?

Tks for all and sorry for my bad english i'm italian.

Sub uno()

Dim conn As ADODB.Connection, rec As ADODB.Recordset

Set conn = New ADODB.Connection

Set rec = New ADODB.Recordset

conn.Open "Dsn=test"

rec.Open ("select * from staff"), conn, adOpenStatic, adLockReadOnly

Debug.Print rec.Fields(0)

Debug.Print rec.Fields(1)

rec.Close

conn.Close

Set conn = Nothing

End Sub

note:

i know the ip od pc where is the dsn

Hi there,
Try the followin to solve the problem..Let me know...
You can adopt this plan.
under control panel, ODBC, create a new DSN (data service Name) point to the access database, enter the user id and password.
and save it after naming it say Test.

use this code in the vb project;

Option Explicit
Dim conn As ADODB.Connection, rec As ADODB.Recordset
'under control panel_odbc create a DSn called Jinnie_test. point it to mdb file and enter user id and password
Private Sub Command1_Click()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Dsn=test" ' test is the DSN Name.
rec.Open ("select * from testable2"), conn, adOpenStatic, adLockReadOnly
Text1 = rec.Fields(0)
Text2 = rec.Fields(1)
rec.Close
conn.Close
Set conn = Nothing
End Sub


Take Care..Buddy..

Tks...for sugestion i know this way.
But the dsn is on other computer not is located in the pc where i run the code(?!)....
How to the script know the ip/pc/ name where the dsn is saved?

1st, if you need to, install the MySQL drivers on the other machine.
2nd, create the ODBC DSN on the other machine to point to your instance of MySQL.
3rd, create an install package with the PDW or Inno and instal program on other computer.

Or to answer your question more directly...

No you cannot have a program on another computer access your ODBC DSN. It needs to be created on the other computer.


Good Luck

This article has been dead for over six months. Start a new discussion instead.