943,829 Members | Top Members by Rank

Ad:
Jul 14th, 2009
0

dsn on other computer of the same lan

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sal21 is offline Offline
22 posts
since Feb 2008
Jul 14th, 2009
0

Re: dsn on other computer of the same lan


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..


Click to Expand / Collapse  Quote originally posted by sal21 ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jinnie_gia is offline Offline
7 posts
since Jul 2009
Jul 14th, 2009
0

Re: dsn on other computer of the same lan

Click to Expand / Collapse  Quote originally posted by jinnie_gia ...

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sal21 is offline Offline
22 posts
since Feb 2008
Jul 14th, 2009
0

Re: dsn on other computer of the same lan

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: delete recordset
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Printing using Print dialog box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC