T
Tony
Dear All,
When I run an example program on the
http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
I received an error message:
"The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.
Source Error:
Line 11: Line 12: DataSet ds = new DataSet();Line 13:
myCommand.Fill(ds, "Authors");Line 14: Line 15:
MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell me
what's wrong? Thanks!
The example code is below:
======================
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
ring"))
MyCommand = New SqlDataAdapter("select * from Authors",
MyConnection)
DS = new DataSet()
MyCommand.Fill(ds, "Authors")
MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
<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"
EnableViewState="false"
/>
</body>
</html>
When I run an example program on the
http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
I received an error message:
"The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.
Source Error:
Line 11: Line 12: DataSet ds = new DataSet();Line 13:
myCommand.Fill(ds, "Authors");Line 14: Line 15:
MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell me
what's wrong? Thanks!
The example code is below:
======================
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
ring"))
MyCommand = New SqlDataAdapter("select * from Authors",
MyConnection)
DS = new DataSet()
MyCommand.Fill(ds, "Authors")
MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
<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"
EnableViewState="false"
/>
</body>
</html>