Runtime error '-2147467259' [Mcrosoft] [ODBC Driver Manager] Data Source name not found and no default driver specified.

Posted on 2006-05-13
Last Modified: 2013-12-03

I have one database called test_project in my local sql server and sql server authetication to this local database as
                Server : (local)
               username : sa
               password :    
password i leave it as "blank password" while installing the sql server.

My program ini file as below

Main DB=Driver={SQL Server};Server=local;Database=test_project ;Uid=sa;Pwd=;

I have encountered some error while running the application however i have configured the system DSN successfully.

Pls help.
Question by:nyee84
    LVL 6

    Expert Comment

    Are you using ADO?

    What's the usage of your INI file? It looks like a connection string. If so, the connection should be:

    Provider=MSDASQL.1;Persist Security Info=False;Data Source=xxx;Uid=sa;Pwd=;

    xxx should be the name of your successfully configured system DSN.
    LVL 52

    Expert Comment

    by:Carl Tawn
    You connection string is attempting to use the ODBC driver, which you probably don't want to be doing as it is much slower than the OLEDB dirvers. Secondly, "local" needs to be enclosed in brackets when referring to a SQL Server.

    Try changing your connection string to:

    LVL 17

    Accepted Solution

    Microsoft advise the use of the UDL Wizzard in order to create your connection string.

    It is very easy to use, and it proves your connection is OK. The following link shows how to create a UDL file.

    So once you have created an empty text file, then renamed as x.udl, just double click on the file and the UDL Wizzard starts running.  Click on the Providers tab and select theProvider for  SQL Server.  (If you don't have a provider it means that you did not install the data access components when you installed VB.)

    Once you have selected the provider, click next and enter the datails of the sql server database.  There is a test button which checks that the connection is OK.

    Once you have a UDL file, a cute thing to do is to open the file and load the provider details into your software.  In this way you can change your SQL server without having to change your code. (You need to employ a few tricks to do this as the file is saved as unicode.)

    Once the connection is tested I edit the file using notepad and change the password, like %PASSWORD%.  In your code you can replace the %PASSWORD% token for the correct password.

    Hope this helps~:)
    LVL 17

    Expert Comment

    Further it is a good idea to create a special user in SQL the server and not to rely on Windows authentication.  This is becuase sometimes your application may be running as an unauthenictaed user, say if it is a web application.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now