Friday, March 30, 2012

problems with useing ms2000 sql

I am new at this and I am getting though a book that is teaching me asp.net
I have experance with vb but I am having truble with the connection to my sql server

<%@. Page Language="VB" debug="true" %>
<script runat="server"
Function MyQueryMethod() As System.Data.SqlClient.SqlDataReader
Dim connectionString As String = "server='68.250.171.129'; trusted_connection=true; Database='working'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [personaldata].* FROM [personaldata]"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)

sqlConnection.Open
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function' Insert page code here
Sub Page_load(sender as object, e as EventArgs)
dgCustomers.DataSource = MyQueryMethod()
dgCustomers.DataBind()
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="dgCustomers" runat="server"></asp:DataGrid>
<!-- Insert content here -->
</form>
</body>
</html
This page works fine when I use the web matrix project, web server. I cannot get it to work when I use my win2000 servers iis server.

this is the error I am getting

Server Error in '/aspnet_client' Application.
------------------------

Invalid object name 'personaldata'.
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: Invalid object name 'personaldata'.

Source Error:

Line 10:
Line 11: sqlConnection.Open
Line 12: Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Line 13:
Line 14: Return dataReader

Source File: D:\server\WEB\aspnet_client\SimpleDataGrid.aspx Line: 12

Stack Trace:

[SqlException: Invalid object name 'personaldata'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +45
ASP.SimpleDataGrid_aspx.MyQueryMethod() in D:\server\WEB\aspnet_client\SimpleDataGrid.aspx:12
ASP.SimpleDataGrid_aspx.Page_load(Object sender, EventArgs e) in D:\server\WEB\aspnet_client\SimpleDataGrid.aspx:17
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

Please can anyone helpYou must make the MACHINENAME\ASPNET Windows user a user in SQL Server. When running in Web Matrix, you are running in your user context, whereas when running in IIS, you are running in the securoty contest of, by default, the ASPNET user.

Note that if SQL is on another box, it might be easier to actually use SQL Server security and send a username and password.|||Thank you I did have that user set up, but it was not connected the that data base

No comments:

Post a Comment