localhost SqlConnection error.

S

StephenRichter

I have SqlServer loaded on my w2k system. The freeby I just downloaded
from MS.

Within WebMatrix I created a database. called it "WebMatrix"

In WebMatrix I connect to the database.
server: (local)
Windows authentication
Database: WebMatrix

all of my web matrix .aspx pages use the following connection string:
myConnection = New SqlConnection(
"Server='abit64';trusted_connection=true; database='WebMatrix'" )

The problem is when I use the IIS server on my w2k PC instead of web
matrix.
http://localhost/viewGuestBookGrid.aspx

I get the following error:

Server Error in '/' Application.
--------------------------------------------------------------------
Login failed for user 'ABIT64\ASPNET'.

The full page that fails follows. I am very confused.

How do I get into SQLServer and config user names and passwords? I
tried to use the system administrator login. no luck. Like I said
before, I have the freeby version that I downloaded from the WebMatrix
sit.

The basic question is why does my sql server connecting code work
using the WebMatrix server and not the IIS server?

thanks,

-Steve


<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

sub Page_Load
dim myConnection as SqlConnection
dim myCommand as SqlCommand
myConnection = New SqlConnection(
"Server='abit64';trusted_connection=true; database='WebMatrix'" )
myCommand = New SqlCommand( "Select * from Guestbook",
myConnection )
myConnection.Open( )
myDataGrid.DataSource = myCommand.ExecuteReader( )
myDataGrid.DataBind( )
myConnection.Close( )
end Sub

</script>
<html>
<head>
<title>View the Guestbook</title>
</head>
<body>
<form runat="server">
<p>
<asp:DataGrid id="myDataGrid"
runat="server"></asp:DataGrid>
</p>
</form>
</body>
</html>
 
S

StephenRichter

srini said:

that helped a lot, srini. thank you!

here are the config commands I had to run:
( WebMatrix is the name of my database. abit64 is the name of the
system. )

- run the osql utility to config sql server
- osql -E -S abit64
- this gives you the osql command prompt

- use WebMatrix
go

- sp_grantlogin 'abit64\aspnet'
go

- sp_grantaccess 'abit64\aspnet'
go

- sp_addrolemember 'db_owner', 'abit64\aspnet'
go

-Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top