script not running

S

Sarah

I am running on MS WinXP Pro. I have my virtual directories set up
properly. If i run just a simple "hello world" application it works
fine. i have the following code, which was downloaded from the
internet from the book that i am using, and it worked fine. but then i
transferred to a new computer so i took all the code and transfered it
over. so the page runs up to the <script>. so i tried moving the code
back to the old computer and it gave me the same problem.
any help would be REALLY appreciated.
(the code uses the northwind database which is installed and the
server is running properly as well.)
here's the code:
file: web.config
***
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true"/>
</system.web>
</configuration>
***
file: sqlserver_connection.aspx
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

<html>
<head>
<title>Beginning ASP.NET Databases Chapter 3</title>
</head>

<body>
<h4>First Example: Listing data from the Employees table</h4>
<asp:DataGrid id="dgNameList"
runat="server"
Gridlines="None"
BackColor="LightBlue"
CellPadding="5"
CellSpacing="5"
BorderWidth="2"
BorderColor="Black"
ToolTip="Includes only those employees who are at
HQ" />
<body>
</html>

<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
Dim strConnection As String = "server=(local)\NetSDK;
database=Northwind; " & _
"integrated security=true"
Dim objConnection As New SqlConnection(strConnection)

Dim strSQL As String = "SELECT FirstName, LastName, Country " & _
"FROM Employees;"
Dim objCommand As New SqlCommand(strSQL, objConnection)

objConnection.Open()
dgNameList.DataSource = objCommand.ExecuteReader()
dgNameList.DataBind()
objConnection.Close()
End Sub
</script>
***
so i know that it is getting to the end of the html tag b/c i put
"hello world" there and it showed up. but the table which is supposed
to show up is not coming up.
any suggestions????
Thank you
 
S

Scott M.

Well, the first thing I see right away is that in your .aspx file, you don't
have your server controls (dataGrid, etc.) inside of a server form. It
should look like this:

<html>
<head>
<title>Beginning ASP.NET Databases Chapter 3</title>
</head>

<body>
<h4>First Example: Listing data from the Employees table</h4>
<form runat="server" id="Form1">
<asp:DataGrid id="dgNameList"
runat="server"
Gridlines="None"
BackColor="LightBlue"
CellPadding="5"
CellSpacing="5"
BorderWidth="2"
BorderColor="Black"
ToolTip="Includes only those employees who are at HQ" />
</form>
<body>
</html>
 

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,123
Latest member
Layne6498
Top