Thanks jbenson001
I made a few changes. Here is the new code
<%@ Page Language="
VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load(Scr As Object, e As EventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
myConnection = new _
SqlConnection("server=GH010033D;uid=sa;pwd=;" _
& "database=pubs")
myCommand = new SqlDataAdapter("SELECT * FROM Authors", _
myConnection)
Dim ds As DataSet = new DataSet()
myCommand.Fill(ds)
MyDataGrid.DataSource = ds
MyDataGrid.DataBind()
End Sub
</script>
<html><body>
<h3>
</h3>
<asp:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
MaintainState="false"
/>
</body></html>
and This is the error I get:
Server Error in '/' Application.
--------------------------------------------------------------------------------
SQL Server does not exist or access denied.
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: SQL Server does not exist or access denied.
Source Error:
Line 17:
Line 18: Dim ds As DataSet = new DataSet()
Line 19: myCommand.Fill(ds)
Line 20:
Line 21: MyDataGrid.DataSource = ds
Source File: c:\inetpub\wwwroot\aspnet\datagrid.aspx Line: 19
Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction) +473
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ASP.datagrid_aspx.Page_Load(Object Scr, EventArgs e) in c:\inetpub\wwwroot\aspnet\datagrid.aspx:19
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
I believe it has something to do with my SQL Server. I have been changing permissions but I still get the same error message. Can andyone help me?
Cheers.