Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Connecting to SQL Server using VB6

Visual Basic 4 / 5 / 6

  • Please log in to reply
1 reply to this topic

#1 JAVAness

JAVAness

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 07 June 2011 - 07:45 PM

Hello, I'm new to MS SQL server. In our class, we were using MS Access Database in storing records. I have no idea how. I already searched for 2 nights on ways on how to connect it. Could someone please guide me on how to establish connection esp. setting up data source in ODBC and the connection string to use (I have really hard time on understanding what data should I put) My system is to be deployed this week by the company but I'm still using MS Access till now.

I have this code now, but I'm not sure if this is it.
Dim MyConnObj As ADODB.Connection 'ADODB Connection Object
        Dim myRecSet As New ADODB.Recordset 'Recordset Object
        Dim sqlStr As String ' String variable to store sql command
        
        Set MyConnObj = New ADODB.Connection
        
        MyConnObj.ConnectionString = "Provider = MSDASQL;" & _
            "Data Source=LocalServer;" & _
            "Initial Catalog=sample;" & _
            "Login ID=SERVANT;" & _
            "Driver=SQL Server;"

        MyConnObj.Open
        
        Set myRecSet = New ADODB.Recordset
        
         sqlStr = "select * from Employee"
         
        myRecSet.Open sqlStr, MyConnObj, adOpenKeyset

What provider should be used? I am using MS SQL Server 2000. Some sites are using SQLOLEDB and others use MSDASQL. I'm so confused right now. What is data source? I only put there LocalServer since it is in System DSN of ODBC and I'm using local. In MS SQL Server - Console Root\Microsoft SQL Servers\SQL Server Group\(local)(Windows NT)
I created a sample database under it and a table called Employee.

Is that the correct connectionString?

I have run this code but i get this error.


Run-time error'-2147467259(80004005)':[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
  • 0

#2 seogreek01

seogreek01

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 08 December 2011 - 12:30 AM

there are a new sql server ?
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download