Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 15th, 2003, 08:40 PM
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem accessing table

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>

 
Old December 16th, 2003, 09:00 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old December 16th, 2003, 04:03 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem accessing the following siblings. Tre XSLT 6 June 5th, 2007 11:13 AM
problem in accessing IIS.... ? webniki Internet Information Services 1 February 25th, 2007 11:24 AM
accessing table values in VB pettrer ASP.NET 2.0 Basics 1 April 22nd, 2006 09:58 AM
Accessing the latest row in a table pramos.21d SQL Language 2 April 6th, 2006 06:56 PM
Accessing a MSAccess table in vc++ using ADO connectprn Classic ASP Databases 0 December 23rd, 2004 03:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.