Results 1 to 3 of 3

Thread: Accessing data from an SQL server

  1. #1
    Guest
    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.


  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Connect to it using ADO and use the OLE DB Provider.

    i.e.
    Code:
    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.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    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.
    Not nearly so tired now...

    Haven't been around much so be gentle...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width