Free2Code
 
Time: 2008-11-21, 08:24pm
How to connect Vb6 with SQL2000
Subject: How to connect Vb6 with SQL2000  ·  Posted: 2006-06-10, 06:22am
Rank: ? (2)
Member #: 27652
I am new to vb, i only know to connect vb with Access using DAO.To connect with SQL 2000 which connectvity to be used and how please help me.

 
  Reply to this ·  Post link ·  Top
Subject: Re: How to connect Vb6 with SQL2000  ·  Posted: 2006-07-21, 02:07pm
Rank: ? (1)
Member #: 27977
1�refers to :
Microsoft Activex Data Objects Recordset 2.6 Library
Microsoft Activex Data Objects 2.6 Library
2�
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Dim mag As String

On Error GoTo strerrmag
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Driver={sql server};server=" 192.168.1.4 & ";uid=" sa ";pwd=" 123456 ";database=" test""
conn.ConnectionTimeout = 30
conn.Open
addFlag = True
Exit Function
strerrmag:
mag = "can't open database "
Call MsgBox(mag, vbOKOnly + 16, "error"
addFlag = False


 
  Reply to this ·  Post link ·  Top
Subject: Re: How to connect Vb6 with SQL2000  ·  Posted: 2006-09-26, 05:39pm
Rank: ? (3)
Member #: 28625
First Add ADO

Microsoft Activex Data Objects 2.6 Library



Public xCn As New ADODB.Connection

On Error GoTo dbaseError


xCn.ConnectionTimeout = 0
xCn.CommandTimeout = 0
xCn.Provider = "SQLOLEDB"
xCn.Properties("Data Source".Value = server Name
xCn.Properties("Initial Catalog".Value = dataBase Name
xCn.Properties("User Id".Value = userId
xCn.Properties("Password".Value = userPwd
xCn.CursorLocation = adUseClient
xCn.Open
Msgbox "Connection Success"
dbaseError:
Msg Box "connection Failed"


Masood

 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons