I have a project in VB6 where I need to get data from a Remote SQL7 server vis ODBC.
Can anybody take me through the steps from connectiong to remote computer to getting the data.
Best Wishes
10-08-2002 at 04:36 PM
|
stickleprojects Level: Moderator Registered: 09-09-2002 Posts: 891
Re: VB6 with ODBC to SQL
Hi,
The simplest way is to use a DSN.
On your control panel, use the ODBC manager to create a new dsn and point it to the remote SQL server.
Your ADO connection string is then "dsn=mydsn;user id=myuid; password=mypwd"
Hope this helps,
Kieron
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
09-09-2002 at 11:59 PM
|
JLRodgers Level: Moderator Registered: 04-04-2002 Posts: 1616
Re: VB6 with ODBC to SQL
A few steps to build the connection string without typing it:
1) Add a "Microsoft ADO Data Control 6.0 (OLEDB)" control to a form. (from the components list)
2) Right click the control, select ADODC properties.
3) Click the Build button.
follow the prompts (SQL is for SQL server, Microsoft Jet is for Access)
4) once you select OK, the connection string needed to connect to the database will be in the "Use connection string" box, copy it.
Use the string for either the control itself, or a connection variable.
For example:
' "Typical" SQL connection
Dim adc as new ADODB.Connection
Set adc = new ADODB.Connection
' Integrated Security = use NT login info
' Initial Catalog= Database name
' Data Source=SQL Server name, (local)=PC program's running on
adc.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=northwind;Data Source=(local)"