By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,314 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,314 IT Pros & Developers. It's quick & easy.

Help me with Sqlconnection string in C#,please

P: n/a
I want to make asp.net application in C# that is connected
with SQL Server database. When I put this connection
string:
SqlConnection conn = new SqlConnection(
"user id=;" +
"password=;server=localhost;" +
"Trusted_Connection=yes;"+
"database=Knjiznica;" +
"connection timeout=30");

try
{
conn.open();
}

catch(SqlException sqle)
{
this.TextBox1 .Text =sqle.Message ;
}
it throws me this error in textbox1: Login failed for
user 'JOSIP-SKY2IGFE7\ASPNET'. where JOSIP-SKY2IGFE7 is
name of my computer.
When I make windows application and put the same
connection string it works!!
What do I need to do that my web applications also works?
Thank you
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
djozy,

The reason this is failing is that you are using the Trusted_Connection
property, which means that it will ignore the user id and password fields.
If you have a specific account to login, remove the Trusted_Connection
property and then place the user name and password there.

The problem arises because ASP.NET (which you are running this in), runs
under the ASPNET user account by default. This account has very limited
permissions. So, to get around that, you either have to change the user
that the page runs under (through the web.config file for the directory), or
elevating the privledges of the ASP.NET user.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"djozy" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I want to make asp.net application in C# that is connected
with SQL Server database. When I put this connection
string:
SqlConnection conn = new SqlConnection(
"user id=;" +
"password=;server=localhost;" +
"Trusted_Connection=yes;"+
"database=Knjiznica;" +
"connection timeout=30");

try
{
conn.open();
}

catch(SqlException sqle)
{
this.TextBox1 .Text =sqle.Message ;
}
it throws me this error in textbox1: Login failed for
user 'JOSIP-SKY2IGFE7\ASPNET'. where JOSIP-SKY2IGFE7 is
name of my computer.
When I make windows application and put the same
connection string it works!!
What do I need to do that my web applications also works?
Thank you

Nov 15 '05 #2

P: n/a
Thank you for your help,but when I launch web.config from
directory where is my application it opens in IE and
throws me this:
This type of page is not served.
Description: The type of page you have requested is not
served because it has been explicitly forbidden. The
extension '.config' may be incorrect. Please review the
URL below and make sure that it is spelled correctly.
What to do?How to open it,or how and where can I eveluate
the privledges of ASP.NET user? I can't find a paper where
I had put my login,and server on wich I work is
localserver.It is in fact my own computer.I have installed
win2000 advanced server on it.
Thank you for your patient.
Nov 15 '05 #3

P: n/a
You can't serve up web.config. Rather, you have to edit the file to
change the configuration. It will be in the same directory as your ASPX
file that is trying to access the page.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<an*******@discussions.microsoft.com> wrote in message
news:b6****************************@phx.gbl...
Thank you for your help,but when I launch web.config from
directory where is my application it opens in IE and
throws me this:
This type of page is not served.
Description: The type of page you have requested is not
served because it has been explicitly forbidden. The
extension '.config' may be incorrect. Please review the
URL below and make sure that it is spelled correctly.
What to do?How to open it,or how and where can I eveluate
the privledges of ASP.NET user? I can't find a paper where
I had put my login,and server on wich I work is
localserver.It is in fact my own computer.I have installed
win2000 advanced server on it.
Thank you for your patient.

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.