PDA

Click to See Complete Forum and Search --> : Accessing data from an SQL server


Nov 16th, 2000, 09:59 AM
I have a database called Employee on a remote SQL server.
The database has a table called CompTime.

I need to know how I can access the data on the CompTime table using VB. I have an ODBC drive to conned to the SQL Server(called TEST) and userid: sa, password: blank.

Could someone help me with the code to connect and access the data from the database.

Thank you.

paulw
Nov 16th, 2000, 10:21 AM
Connect to it using ADO and use the OLE DB Provider.

i.e.

Dim cn As New Connection
cn.ConnectionString = "DSN=Test;UID=sa" ' or whatever
cn.Open

Dim rs As Recordset
rs.Open Source:="SELECT * FROM CompTime", ActiveConnection:=cn

etc.

The Source:="..." syntax is named argument, so you do not have to remember the position or put in loads of commas.

Check out the Microsoft site for and ADO overview.

Hope that helps.

Paul.

paulw
Nov 16th, 2000, 10:40 AM
shuj66,

I've just seen your earlier post. As a relative newbie, you would find it much easier to use the DataEnvironment and use bound controls. Check out barrk's answer to your earlier post.

P.