Results 1 to 5 of 5

Thread: connect to Ms SQL Server DB ! [resolved]

  1. #1

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Resolved connect to Ms SQL Server DB ! [resolved]

    any wizard help to connect to the database in vb6? vb .net does hav wizard help in connecting to database. feels strange suddenly go backward.
    Last edited by babyekc; Jan 28th, 2005 at 02:29 AM.
    *wink wink*

    _babyekc

  2. #2
    New Member
    Join Date
    Jan 2005
    Posts
    8

    Re: connect to DB !

    I use Access with DB6 all the time. You have to create a data environment with the info about the database first and then you can create objects that connect to the environment (fields, sliders, grids, etc...)
    Lance

  3. #3

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: connect to DB !

    well, im using Ms SQL Server. could anyone can giv some example code which showing the way of connecting to the database?
    *wink wink*

    _babyekc

  4. #4
    Lively Member Misspell's Avatar
    Join Date
    Mar 2002
    Location
    Located
    Posts
    69

    Re: connect to Ms SQL Server DB !

    Heres how i have done it...

    In a Module (just cause i use the connections through out my project)...
    You will have to change 'DBASE_NAME' and 'YOURPASSWORD' along with the I.P.
    1433 is the SQL port.
    Code:
    Global Const Dbase = "Provider=sqloledb;" & _
      "Data Source=192.168.0.11,1433;" & _
      "Network Library=DBMSSOCN;" & _
      "Initial Catalog=DBASE_NAME;" & _
      "User ID=sa;Password=YOURPASSWORD;"""
    
    Public cn As ADODB.Connection
    Public rs As ADODB.Recordset


    Then in the form...
    Code:
    Set cn = New ADODB.Connection
          cn.Open Dbase
    
    
     Set rs = New ADODB.Recordset
         rs.Open "SELECT * FROM TABLE_NAME", cn, adOpenStatic, adCmdText
    
       Do Until rs.EOF
             Text1.text = rs.Fields("Col_Name") & vbcrlf
           rs.MoveNext
       Loop
    
        rs.Close
    Set rs = Nothing

    _

    ~ What was once an opinion, became a fact, to be later proven wrong... ~

  5. #5

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: connect to Ms SQL Server DB !

    IP address must put my IP follow by 1433? What is adOpenStatic and adCmdText?
    *wink wink*

    _babyekc

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