Re: SQL Server Connection Declearation
From: Douglas J. Steele (NOSPAM_djsteele_at_NOSPAM_canada.com)
Date: 10/09/04
- Next message: Juan Erickson Guzmán: "Problems refreshing a table"
- Previous message: Melvin.Ding: "SQL Server Connection Declearation"
- In reply to: Melvin.Ding: "SQL Server Connection Declearation"
- Next in thread: Melvin.Ding: "Re: SQL Server Connection Declearation"
- Reply: Melvin.Ding: "Re: SQL Server Connection Declearation"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 9 Oct 2004 05:14:24 -0400
You need to set a reference to ADO.
Alternatively, you could use late binding, and replace
Set cn = New ADODB.Connection
with
Set cn = CreateObject("ADODB.Connection")
Of course, if you don't have a reference set to ADO, then your program won't
know the value of intrinsic constants (such as adUseServer, which you use
near the end). That means you'll either have to use the actual value of the
constant (2 in this case), or else define the constants to the program.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Melvin.Ding" <melvin.ding@photoptech.com> wrote in message news:epJ3LcdrEHA.4004@TK2MSFTNGP10.phx.gbl... > Hello, > > I just tried to build a database connection from vb6.0 to SQL Server 8.0 to > perform a simple query. See the codes below: > > Private Sub cmdSearch_Click() > > Set cn = New ADODB.Connection > connstr = "Data Source=OPEN_VIEW;User=sa;Password=;" > cn.Provider = "SQLOLEDB" > cn.ConnectionString = connstr > cn.Open > cn.DefaultDatabase = "employee" > sql = "Select * from employee" > Set rs = New ADODB.Recordset > Set rs.ActiveConnection = cn > rs.CursorLocation = adUseServer > rs.Open sql, cn, adOpenKeyset, adLockOptimistic > End Sub > > When I compiled the codes, IDE shows that "ADODB.Connection" is unknown > user_define variable data type. So what are the steps I should take to make > the declearation "Set cn = New ADODB.Connection" valid? > > thanks. > >
- Next message: Juan Erickson Guzmán: "Problems refreshing a table"
- Previous message: Melvin.Ding: "SQL Server Connection Declearation"
- In reply to: Melvin.Ding: "SQL Server Connection Declearation"
- Next in thread: Melvin.Ding: "Re: SQL Server Connection Declearation"
- Reply: Melvin.Ding: "Re: SQL Server Connection Declearation"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|