Jump to content

Connecting to SQL Server using VB6

- - - - -

  • Please log in to reply
1 reply to this topic

#1
JAVAness

JAVAness

    Newbie

  • Members
  • Pip
  • 1 posts
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

#2
seogreek01

seogreek01

    Newbie

  • Members
  • Pip
  • 3 posts
there are a new sql server ?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users