Results 1 to 5 of 5

Thread: How to connect to a database in the server

  1. #1
    Guest

    Question

    Hi all

    I am new in visual basic and am creating a application in visual basic which has a central database which is there in the server on the lan env. but how can i connect user to the server for accessing the database from the server from the terminal

    how ? please help me out
    thanks


  2. #2
    Member
    Join Date
    Nov 2000
    Location
    Manila, Philippines
    Posts
    51
    There are a number of ways to connect to that database...
    But Im gonna teach you something which I think would be best....

    It depends on the database that you have... However, one thing is common, configuring windows' ODBC data sources, you can connect to any database on other machines, provided you have the drivers for those databases.... (are u familiar with windows ODBC?)...

    Like Sybase's SQL Server Anywhere.. or Enterprise blah blah..... and so on and so forth, the danger is you might not have those drivers installed on the client. Each vendor has its own installer for this.

    But if its an MS Access Database (*.MDB), windows has it by default. So you can easily configure ODBC on the client machine, to point to that database on the server. You then need DAO or ADO(I prefer ADO) to connect to the ODBC data source on the client machine. It will be the ODBC which will be responsible for connecting to the remote database(on the server).

    Prerequisite: knowledge on ADO or DAO, knowledge on Configuring ODBC data sources on Windows...

    I really hope this helps.

    Programmers dont byte, they just nibble a bit.

  3. #3
    Guest
    what kind of a database are you trying to connect to, anyway? you might want to try adding a data environment to your program. just hit Project, then Add Data Environment. Then right click on Connection1 and hit properties, and then alter the properties to your specifications.

    Then you can use the Data View Window button to drag and drop the tables/queries that you need.

    hope this helps.

  4. #4
    New Member
    Join Date
    Jan 2000
    Location
    Stellenbosch, South Africa
    Posts
    12
    I connect to an Access databases using the following code:

    Public Function Gain_DB_Access()

    On Error GoTo ErrorHandler

    MyPath = CurDir
    Set DB = DBEngine.Workspaces(0).OpenDatabase(MyPath & "\data\SAPChx.mdb", False, False, ";pwd=SaPcHxX")

    ErrorHandler: ' Error-handling routine.
    If Err.Number <> 0 Then
    MsgBox ("Error " & Err.Number & " " & Err.Description & " occurred!")
    Else
    Exit Function
    End If


    End Function

    +++++ Code above in my module +++++

    +++++ Code below access the database +++++

    Data3.DatabaseName = MyPath & "\data\SAPChx.mdb"
    Data3.Refresh ' Open the Database.
    Data3.Recordset.MoveFirst
    t1_host = Data3.Recordset.Fields("T1_Host").Value
    t2_host = Data3.Recordset.Fields("T2_Host").Value
    Data3.Database.Close


    Hope this helps.


  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    1) Don't use ODBC to connect to an Access database, use the OLE-DB Provider instead.

    2) Don't use DAO when you can use ADO.

    3) If you are planning on more than 10 users to be accessing your database at once, don't use Access at all.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

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