Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to SQL Server 2000

Status
Not open for further replies.

joelxez

Programmer
Apr 18, 2002
67
PH
Dear experts,

Any one can help me on how to connect to MS SQL server 2000 using vb6?
 
there are many ways.. You can use a Provider, or an ODBC driver:

with an ADODB control:
Load an ADODB control from the component window, and set its connection string using the sql driver.

Crearing a connection:
or go to Control Panel, ODBC drivers and create a new driver for Your SQL database, You can refer in Your application to it by its name.

for example:

Code:
Dim conn as new adodb.connection
conn.open "ODBCNAME"

** You can combine both methods above.. all the connection string will work for both.

i hope it helps

Eli
 
Dim SQLCON As ADODB.Connection
Dim SQLRS As ADODB.Recordset

' Set the ADO SQLCON properties.
Set SQLCON = New ADODB.Connection
Set SQLRS = New ADODB.Recordset

With SQLCON
.ConnectionTimeout = 25 ' Time out for the SQLCON
.Provider = "sqloledb" ' OLEDB Provider
.Properties("Network Address").Value = "999.999.999.999" ' Set the ip address of your sql server
.CommandTimeout = 180 ' Set timeout for 3 minutes
.Properties("Network Library").Value = "dbmssocn" ' Set the network library to use win32 winsock tcp/ip
.CursorLocation = adUseServer ' For ADO cursor location
.Properties("User ID").Value = "xx" ' Set the user id
.Properties("Password").Value = "xxxxxxxxxxxxxx" ' Set the password
.Properties("Data Source").Value = "999.999.999.999" ' Set the ip address as the datasource
.Properties("Initial Catalog").Value = "xxxxxxxx" ' Set the database name
.Open
End With

With SQLRS
.Open "SELECT * FROM TABLENAME;", SQLCON, adOpenStatic, adLockReadOnly, adCmdText
End With

SQLRS.Close
SQLCON.Close
Set SQLCON = Nothing

Swi
 
Swi,


Tnx, these would help me.


joelxez
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top