I am having a problem with .net ms sql connections...
My situation: I log onto my computer (Windows XP Pro) using the administrator account.
I have MSDE installed, with NT authorization.
I created a quick connection in ASP.net Web Matrix, and ran the code using the ASP.NET web matrix server - It ran perfectly, so i know the connection string is good, and so is all the other code i used for the connection... I know that it used the administrator account to access the sql server.
Then i copied and pasted the exact working code i had in web matrix to Visual Studio.net, and tried to run it using IIS, but it gave the following error:
Server Error in '/' Application.
Login failed for user 'DAVID\ASPNET'.
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.Data.SqlClient.SqlException: Login failed for user 'DAVID\ASPNET'.
Source Error:
Line 11: Dim myCommand As New SqlCommand(CommandText, myConnection)
Line 12:
Line 13: myConnection.Open()
Line 14:
Line 15: ' Create Instance of Connection and Command Object
I only have MSDE installed on my PC, so i ran the following in DOS:
cd "c:\Program Files\Microsoft SQL Server\80\Tools\Binn"
osql -E -S DAVID -Q "sp_grantlogin 'DAVID\ASPNET'"
osql -E -S DAVID -d myDB -Q "sp_grantdbaccess 'DAVID\ASPNET'"
osql -E -S DAVID -d myDB -Q "sp_addrolemember 'db_owner', 'DAVID\ASPNET'"
pause
So now ASPNET should have full access to the sql server. (Stored Procedures ran fine, and the roles and accounts were created successfully.)
So i ran the ASP.net code in IIS again, but still the same error!
I have even tried re-installing asp.net!
I havent tried re-installing MSDE because i dont want to loose my data, but if i have to, then i guess i have to... :(
What do i do??I'm sure you understood, that your SQL Server did not accept DAVID\ASPNET as a login name?! Either there is indeed not such a user, or maybe you took the back-slash instead the slash. Could you post your connection string?|||I will get the connection string to you asap - its at home, not at work, so only tomorrow...
When installing the .NET framework, the user ASPNET is automatically added. ASP.NET uses this user for all the interaction it makes with the server (in most cases). So anyway - the ASPNET user is there, and my computer name is DAVID, and so is my SQL server instance called DAVID.
Ill try with the forward slash instead of using a back slash, but im pretty sure that i did it the right way... I copied it exactly as the asp error page had it...
Showing posts with label david. Show all posts
Showing posts with label david. Show all posts
Thursday, March 22, 2012
DAVID/ASPNET Sql connection problem!
David Portas on Any one? Query Help Please
Thanks for your response.
I got that query working,
SELECT P.productname, COUNT(S.productname)
FROM Products AS P
LEFT JOIN Sales AS S
ON P.productname = S.productname
GROUP BY P.productname ;
but what if there was another column CustomerId, which exists in both tables
and I want to just see products just for a particular customer?
So if a product is offered to a customer , but he doesn't order it then in
result I want to show that product with count as 0...Try this:
SELECT P.productname, COUNT(S.productname)
FROM Products AS P
LEFT JOIN Sales AS S
ON P.productname = S.productname
AND P.customerid = S.customerid
WHERE P.customerid = /* specify the required customer */
GROUP BY P.productname ;
The best way to get help with a problem such as this is to post DDL and
sample data. The following artcile explains how:
http://www.aspfaq.com/etiquette.asp?id=5006
David Portas
SQL Server MVP
--|||Thnx David,
It worked for me.
"David Portas" wrote:
> Try this:
> SELECT P.productname, COUNT(S.productname)
> FROM Products AS P
> LEFT JOIN Sales AS S
> ON P.productname = S.productname
> AND P.customerid = S.customerid
> WHERE P.customerid = /* specify the required customer */
> GROUP BY P.productname ;
> The best way to get help with a problem such as this is to post DDL and
> sample data. The following artcile explains how:
> http://www.aspfaq.com/etiquette.asp?id=5006
> --
> David Portas
> SQL Server MVP
> --
>
>sql
I got that query working,
SELECT P.productname, COUNT(S.productname)
FROM Products AS P
LEFT JOIN Sales AS S
ON P.productname = S.productname
GROUP BY P.productname ;
but what if there was another column CustomerId, which exists in both tables
and I want to just see products just for a particular customer?
So if a product is offered to a customer , but he doesn't order it then in
result I want to show that product with count as 0...Try this:
SELECT P.productname, COUNT(S.productname)
FROM Products AS P
LEFT JOIN Sales AS S
ON P.productname = S.productname
AND P.customerid = S.customerid
WHERE P.customerid = /* specify the required customer */
GROUP BY P.productname ;
The best way to get help with a problem such as this is to post DDL and
sample data. The following artcile explains how:
http://www.aspfaq.com/etiquette.asp?id=5006
David Portas
SQL Server MVP
--|||Thnx David,
It worked for me.
"David Portas" wrote:
> Try this:
> SELECT P.productname, COUNT(S.productname)
> FROM Products AS P
> LEFT JOIN Sales AS S
> ON P.productname = S.productname
> AND P.customerid = S.customerid
> WHERE P.customerid = /* specify the required customer */
> GROUP BY P.productname ;
> The best way to get help with a problem such as this is to post DDL and
> sample data. The following artcile explains how:
> http://www.aspfaq.com/etiquette.asp?id=5006
> --
> David Portas
> SQL Server MVP
> --
>
>sql
Subscribe to:
Posts (Atom)