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 February 9th, 2005, 10:23 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nagen111 Send a message via Yahoo to nagen111
Default problem 2 connecting SQL Server 200 using ASP.NET

Dear Alll,

I am trying to connect MS SQL Server 2000 using ASP.NET with C# , Application with given Code :

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Language="C#" runat="Server">
    void Page_Load()
    {

        string strConnection = "user id=su;password=;";
        strConnection += "initial catalog=northwind;server=HOME;";


        data_src.Text = strConnection;
        SqlConnection objConnection = new SqlConnection(strConnection);
        try
        {
            objConnection.Open();
            con_open.Text="Connection opened successfully.<br />";
            objConnection.Close();
            con_close.Text="Connection cloased.<br />";
        }
        catch (Exception e) {
            con_open.Text="Connection failed to open.<br />";
            con_close.Text=e.ToString();

        }
    }
</script>
<html>
    <body>
    <h4>testing the Data Connection.<BR>
    <asp:label id="data_src" runat="server" /></h4>
    <asp:label id="con_open" runat="server" /><br />
    <asp:label id="con_close" runat="server" /><br />
    </body>
</html>
__________________________________________________ __

After executtin ggetin Error :

testing the Data Connection.
user id=su;password=;initial catalog=northwind;server=HOME;
Connection failed to open.

System.Data.SqlClient.SqlException: Login failed for user 'su'. Reason: Not associated with a trusted SQL Server connection. at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at ASP.sql_connection_aspx.Page_Load()

pls. help me as soon as possible.

Nagen

 
Old February 10th, 2005, 12:26 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Try using "trusted connection=yes" in your connection string .. i think that would solve your issue.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old February 10th, 2005, 09:13 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nagen111 Send a message via Yahoo to nagen111
Default

Dear Vadivel,

You mean i have to used syntax like this

1. string strConnection = "trusted_connection=yes";
   strConnection += "initial catalog=northwind;server=HOME;";

or i should use in this way..

2.
 string strConnection = "user id=sa;password=;trusted_connection=yes";
 strConnection += "initial catalog=northwind;server=HOME;";

or 3.

string strConnection = "Integrated Security=SSPI;Trusted_Connection=yes;";
strConnection += "initial catalog=northwind;server=home;";

Now when i using 1. then gettig error

1. Invalid value for key 'integrated security'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid value for key 'integrated security'.

2. Invalid value for key 'integrated security'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid value for key 'integrated security'.


NAD WHEN USING 3 OPTION GETTING ERROS LIKE BELOW : -

3. testing the Data Connection.
Integrated Security=SSPI;Trusted_Connection=yes;initial catalog=northwind;server=home;
Connection failed to open.


System.Data.SqlClient.SqlException: Login failed for user 'HOME\ASPNET'. at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at ASP.sql_connection_aspx.Page_Load()


Pls. help me as soon as possible.

Regards,
Nagen111






 
Old February 11th, 2005, 03:51 AM
Authorized User
 
Join Date: Dec 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kk_katepally Send a message via Yahoo to kk_katepally
Default

Try using UID=sa;pwd=sa instead of user id=su.
Respond me.

bye


kittu
 
Old February 11th, 2005, 08:22 AM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nagen111 Send a message via Yahoo to nagen111
Default

Dear Kittu,

i am login to SQL server 2000 with windows's login and password.

os i think i have to used trusted connection so now let me hwta will be the proper syntax, i ahave used syntax in 3 differents sysntax and getting errors in all .

pls. help me with complete syntax.
Regards,
Nagen111

 
Old February 16th, 2005, 01:26 AM
Registered User
 
Join Date: Feb 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ripplecreations
Default

If u r using Windows Authentication then use windows username and password in connection string not "sa",

System.Data.SqlClient.SqlException: Login failed for user 'HOME\ASPNET'. at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction) at ...

the above error is because ur not passing username and password and ASP.Net engine is using the username under which it is running.. and ASPNET account has got limitations and cannot access SQL server.

Check it out.. it should solve ur problem..

Cheers
Mujahid





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem connecting to sql server rajanikrishna ASP.NET 2.0 Basics 1 September 5th, 2007 04:47 PM
Problem with AGGREGATE FUNCTIONS in SQL SERVER 200 vikiboye SQL Server 2005 1 February 20th, 2006 12:07 PM
Connecting to Sql server database with ASP.NET Abins ASP.NET 1.0 and 1.1 Basics 3 February 17th, 2006 06:56 PM
generate XML from SQL server 200 table sasidhar79 SQL Server DTS 0 August 2nd, 2005 04:47 PM
ASP error when connecting to a new SQL server Cinderella Classic ASP Basics 2 June 21st, 2005 10:00 AM





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