Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 21st, 2007, 02:51 AM
Registered User
 
Join Date: May 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default connection error

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace = "System.Data.SqlClient" %>

<script runat="server" language="c#">
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Driver={SQL Server};SERVER=winsql3.abac.com;Database=jgrant_aw cconnect;" +
"UID=xxx;PWD=xxx");
SqlCommand comm = new SqlCommand("SELECT txt_username FROM jgrant_awcconnect.dbo.usr_user", conn);
conn.Open();
SqlDataReader reader = comm.ExecuteReader();
employeesLabel.Text = (string)reader["txt_username"];
reader.Close();
conn.Close();
}
</script>
    <body>
        <form runat="server">
            <asp:Label ID="employeesLabel" runat="server" />
        </form>
     </body>

I left off some of the html tags for space sake. For some reason I keep getting an error. The error message says "Keyword not supported: 'Driver'"

I tried it without the driver tag but it didnt work either. It passed the compiler but did not connect properly. This connection matches to a .udl generated connection string but it still throws an exception. So I am kind of thinking now that I am doing something wrong above and that the connection string may be right? Am I on the right track here?

 
Old May 22nd, 2007, 08:00 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When you use a SqlConnection, the connection inherently knows what driver to use when it connects to SQL Server, so you don't need to specify that. You just need the details of which server/data/user. Remove the driver part of the string.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection Error asters .NET Framework 1.x 3 April 4th, 2008 12:46 AM
Connection Error kingroon Classic ASP Basics 3 January 10th, 2008 08:48 PM
Connection Error zaghmout ASP.NET 2.0 Professional 3 October 31st, 2007 01:55 AM
connection error janees ASP.NET 2.0 Professional 1 March 2nd, 2007 02:26 PM
Connection Error: Please Help code_lover ADO.NET 3 February 6th, 2007 10:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.