Results 1 to 2 of 2

Thread: connect from access using system DSN

  1. #1

    Thread Starter
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179

    Unhappy connect from access using system DSN

    how can i use a system dsn in access VBA?

    i want to call a stored procedure 'sp_InsertText'
    and i have a system dsn 'sys_Data'


    what code do i need to call this stored procedure in access?

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    From within Access you can use DAO (or add a reference to ADO)
    With DAO you can use ODBCDirect to access.

    VBA Code
    VB Code:
    1. Dim db As DAO.Database
    2.     Dim ws As DAO.Workspace
    3.    
    4.     Set ws = DBEngine.CreateWorkspace("", "", "", dbUseODBC)
    5.     Set db = ws.OpenConnection("", , , "ODBC;DSN=sys_Data;uid=UserNameHere;pwd=PasswordHere;")
    6.  
    7.     db.Execute "{ call sp_InsertText}"

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