Microsoft Knowledge Base Email Alertz

KBAlertz.com: (316321) - When you try to set the ConnectionString property for a SqlConnection object at design time, the OLEDB DataLinks dialog box permits you to select any OLE DB provider on your system to generate a connection string for the SqlConnection object. When you...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 316321 - Last Review: May 13, 2007 - Revision: 2.5

BUG: The SqlConnection object presents misleading user interface for the ConnectionString property

This article was previously published under Q316321
This article refers to the following Microsoft .NET Framework Class Library namespaces:
  • System.Data
  • System.Data.OleDb
  • System.Data.SqlClient

On This Page

SYMPTOMS

When you try to set the ConnectionString property for a SqlConnection object at design time, the OLEDB DataLinks dialog box permits you to select any OLE DB provider on your system to generate a connection string for the SqlConnection object. When you try to run the application, however, you may receive an error depending on which provider you have selected.
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.

CAUSE

The SqlConnection object is used only for connecting to SQL Server.

RESOLUTION

If you want to connect to other data providers, use the OledbConnection or OdbcConnection object.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Studio .NET.
  2. Create a new Windows Application in Visual Basic .NET. Form1 is added to the project by default.
  3. Make sure that your project contains a reference to the System.Data namespace.
  4. Place a Command button on Form1. Change the Name property of the button to btnTest, and then change the Text property to Test.
  5. Use the Imports statement on the System and System.Data namespaces so that you are not required to qualify declarations in those namespaces later in your code. Add this code to the "General Declarations" section of Form1:
    Imports System
    Imports System.Data
    Imports System.Data.OleDb
    Imports System.Data.SqlClient
    					
  6. Drag a SqlConnection object to the form.
  7. In the Properties window, select New Connection for the ConnectionString property.
  8. In the Data Link Properties window, click the Provider tab, select Micrososft Jet 4.0 OLE DB Provider, and then click Next.
  9. Select a sample Access database and then click OK.
  10. Paste the following code in the btnTest Click event:
        Dim da = New SqlDataAdapter("SELECT * FROM Customers", SqlConnection1)
        Dim ds As New DataSet()
        da.Fill(ds, "Customers")
        MessageBox.Show("Connected Successfully")
    					
  11. Save your project. On the Debug menu, click Start to run your project.
  12. Click Test. The code fails with the exception mentioned in the "Symptoms" section of this article.
  13. Change the ConnectionString as necessary for your environment, and then save and run your project.
  14. Click Test. The connection is made successfully.

REFERENCES

For more information about ADO.NET objects and syntax, see the following topic in the Microsoft .NET Framework Software Development Kit (SDK) documentation or MSDN Online:
Accessing Data with ADO.NET
http://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx)
For more information about .NET Managed Providers, see the .NET Developer's Center or the following Microsoft Web site:
Inside .NET Managed Providers
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndive/html/data010112001.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndive/html/data010112001.asp)

APPLIES TO
  • Microsoft ADO.NET (included with the .NET Framework)
  • Microsoft ADO.NET 1.1
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2003 Professional Edition
Keywords: 
kbvs2002sp1sweep kbbug kbnofix kbsqlclient kbsystemdata KB316321
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please