473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help me with Sqlconnection string in C#,please

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
3 5317
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Bill | last post by:
When I compile the following code fragment, the compiler errors saying the variable connection is not initialized. As I understand C#, I thought it would be initialized. Please help me and explain...
3
by: Justnew | last post by:
Hei All Can some body help me here: I have a database name Customers, I a trying to connect to SQL server through vb.net using asp.net webform. I want to connect to the server programatically...
0
by: Nate Hekman | last post by:
I'm trying to set up a Membership/Role Provider for an ASP.NET 2.0 beta 2 site using SqlMembershipProvider, and am having problems configuring SQL Server. I'm comfortable with ASP.NET but very...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
1
by: teddymeu | last post by:
hi guys I posted the other day regarding a solution i needed to design, im new to development an asp,net and built a local post office search tool using asp.net 2. vb in visual studio, using an...
1
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
0
by: hshah | last post by:
Hello All, I have created a .aspx page with 7 text boxes and a save button. On click event following code is fired. It save the property information to sql server and also generate a unique Id...
3
by: weird0 | last post by:
I have two tables accounts and ATM and i am trying to insert a tuple in ATM with accountId as foreign key. But even this simple work,I encounter the following error: The INSERT statement...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.