|
Subject:
|
Problem accessing table
|
|
Posted By:
|
tlamazares
|
Post Date:
|
12/15/2003 7:40:25 PM
|
Hello! I have the following code and all I'm getting is the heading but not the table. Any suggestions are appreciate it. Anthony
<%@ 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()
Response.Write("ServerVersion: " & objConnection.ServerVersion & _ vbCRLF & "Datasource: " & objConnection.DataSource & _ vbCRLF & "Database: " & objConnection.Database)
dgNameList.DataSource = objCommand.ExecuteReader() dgNameList.DataBind() objConnection.Close() End Sub </script>
|
|
Reply By:
|
planoie
|
Reply Date:
|
12/16/2003 8:00:38 AM
|
The header of what? The header of the HTML or the header of the datagrid? You don't have the runat=server form tag, which all web forms should have. I'm not sure if this would cause a problem or not.
Peter ------------------------------------------------------ Work smarter, not harder.
|
|
Reply By:
|
alyeng2000
|
Reply Date:
|
12/16/2003 3:03:21 PM
|
there is no problem with the script i have tested it,except i changed the connection string to work on my sqlServer Config.
also you forgot to end the body tag as </body>
Ahmed Ali Software Developer
|