"news.verizon.net" <ma*@hotmail.com> wrote in message
news:ip*****************@nwrddc01.gnilink.net...
I have a database in SQL2K and I want to write a small program in VB6.
Once I create program in VB6, it should work from any client's
computer.
My SQL database is sitting on share drive X on the w2k server. My
sql2k server name is MYSERVER, my database name is MYDATABASE and table name
is MYTABLE.
I do not want to set up ODBC connection on each computer. I want to
set up in the program so I do not have to go thru each computer each time I
write any program.
Thanks.
Use ADO (Add a Reference to Microsoft ActiveX DataObjects).
The code will look vaguely like this. You will need to lookup the
various methods, check the parameters, and get the values right for your
particular setup.
Dim oConn as Connection
Dim oRecSet as Recordset
Set oConn = New Connection
Call oConn.Open ( "Provider=SQLOLEDB.1;Initial Catalog=mydatabase;Data
Source=MyServer", UserName, PW)
set oRecSet = New Recordset
call oRecSet.Open("SELECT RecID From tblSample", oConn, adOpenStatic,
adLockOptimistic)
You can use the Microsoft ADO Data Control to setup your first
connection, and get the connection string from it, although I would not
use the control itself in an application.
Hope this helps.
Steve