473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error in displaying data grid

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><font face="Verdana">
Simple Select to a DataGrid Control.
</font></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

Dec 1 '06 #1
1 929
Yup can already

Thanks for the help.

Ken wrote:
Try

Select * from [User]

Ken
-------------------------

"Death" wrote:
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><font face="Verdana">
Simple Select to a DataGrid Control.
</font></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
Dec 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: SenthilSS | last post by:
My application produces XML Data files which have XML namespace qualified XML elements (nodes), but the namespace itself is not declared in the data file. My task is to read these data files in a...
2
by: VM | last post by:
When I display data to a Windows datagrid I usually fill the underlying table (in another class) and then, once it contains all the data, I attach it to the grid. But there are some processes that...
2
by: scott | last post by:
Hi all, Iv got a slight problem with a datagrid and the ability to only display certain things in it. I have a Data grid which is connected to a data table. The data table is connected...
4
by: Jon | last post by:
Hi, suspect there might not be a good answer to this one. Using vb.net I have a page like this some text datagrid repeater Now the repeater is populated from a simple query that takes no time...
5
by: Lisa Calla | last post by:
Hi, I need to display records with lots of fields. When placed in a grid, a row of data will scroll off the screen. Not exactly what I'm looking for. I've also used a datalist, which allows...
7
by: What-a-Tool | last post by:
Have an Access table loaded into a DataTable that was created at run time, and am displaying these contents in a data grid. Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games") I would like to...
1
by: thf | last post by:
Hi, I wish to know how to display a collection of object which is a property in another object in a data grid in VB.Net. For example, I'm displaying a collection of vendor objects (in ArrayList)...
1
by: Death | last post by:
Hi all I am having some trouble on displaying datagrid data from my database as i am a beginner for this The error is when calling the DBCommand . It show incorrect syntax near User. But User...
2
by: mili123 | last post by:
Hi I am a new developer.I am having a problem with data grid and datalist. I set datagrid properties (datasource and datamember)at design time and called sqldataadapter's fill method on form load...
1
by: =?Utf-8?B?SmFjaw==?= | last post by:
Hi, I have a simple code where I am trying to capture a recordset in a grid veiw using a button click event. Data is connected to sql server 2000. However, I am getting error at the line...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.