D
Death
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>
<ASPataGrid 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
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>
<ASPataGrid 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