|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error in displaying data gridI 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 Try
Select * from [User] Ken ------------------------- Show quoteHide quote "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 > > Yup can already
Thanks for the help. Ken wrote: Show quoteHide quote > 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 > > > >
Changing Color of Textbox on Hover
Offline application for reporting and collect data Email Socket Question Fastest String search Report Viewer Asynchronous thread abort error No Response Redirect but something like Response Forward? Disable sort on specific columns with VB.NET datagrid Find Window Question What does this mean? Is user admin? |
|||||||||||||||||||||||