Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
Looking for ADO statement for SQL Database
Old
  (#1)
news.verizon.net
Guest
 
Posts: n/a
Default Looking for ADO statement for SQL Database - 06-04-2007, 08:53 AM

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.


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Looking for ADO statement for SQL Database
Old
  (#2)
Steve Gerrard
Guest
 
Posts: n/a
Default Re: Looking for ADO statement for SQL Database - 06-04-2007, 08:53 AM


"news.verizon.net" <EMAIL REMOVED> wrote in message
news:ipNyb.11358$EMAIL REMOVED...
> 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


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Looking for ADO statement for SQL Database
Old
  (#3)
Bob Butler
Guest
 
Posts: n/a
Default Re: Looking for ADO statement for SQL Database - 06-04-2007, 08:53 AM

"news.verizon.net" <EMAIL REMOVED> wrote in message news:<ipNyb.11358$EMAIL REMOVED>...
> 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.


create a UDL file and distribute that with your app and open your
connection using: connection.Open "file name=pathtotheuldfile;"

or just embed the connection string in your app
connection.open "Provider=SQLOLEDB.1;Data Source=MyServer...."
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top