Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 1st, 2006, 01:02 PM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in displaying datagrid

Hi all

I am having some trouble on displaying datagrid data from my database

Below is the code sample :

<%@ Page Language="VB" Debug ="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language ="VBSCRIPT" runat="server">
Sub Page_Load(Src As Object, e As EventArgs)
        Dim myConnection As SqlConnection
        Dim DBCommand As SqlDataAdapter
        Dim DSPagedata As New DataSet

        myConnection = New _
        SqlConnection("server=localhost;uid=sa;pwd=;" _
        & "database=test1")

        Dim QueryString As String = "select * from User"

        DBCommand = New SqlDataAdapter(QueryString, _
        myConnection)
        DBCommand.Fill(DSPagedata, "User")---error line

        MyDataGrid.DataSource = DSPagedata.Tables("User")
        MyDataGrid.DataBind()
    End Sub
</script>

<html><body>
<h3>
Simple Select to a DataGrid Control.
</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>



The error is when calling the DBCommand . It show incorrect syntax near User. But User is the table in my server. Did i do anything wrong?
Pls advice .Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying Columns in a DataGrid jmss66 VB How-To 0 July 26th, 2007 03:13 PM
Displaying Images in a DataGrid RichardOrmiston ASP.NET 1.0 and 1.1 Basics 1 December 13th, 2005 01:13 PM
Displaying 2 datatables in 1 datagrid muskaanbajaj Classic ASP Databases 5 May 19th, 2005 11:36 AM





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