Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."

Reply
Thread Tools

ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."

 
 
Tony
Guest
Posts: n/a
 
      06-15-2004
Dear All,
When I run an example program on the
http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
ring"))
MyCommand = New SqlDataAdapter("select * from Authors",
MyConnection)
DS = new DataSet()
MyCommand.Fill(ds, "Authors")
MyDataGrid.DataSource=ds.Tables("Authors").Default View
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>


 
Reply With Quote
 
 
 
 
Martin Marinov
Guest
Posts: n/a
 
      06-15-2004
do you have a web.config file with these lines

<appSettings>
<add key="PubsString" key="your connectionstring here" />
</appSettings>

Regards
Martin


"Tony" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear All,
> When I run an example program on the
>

http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
> ring"))
> MyCommand = New SqlDataAdapter("select * from Authors",
> MyConnection)
> DS = new DataSet()
> MyCommand.Fill(ds, "Authors")
> MyDataGrid.DataSource=ds.Tables("Authors").Default View
> 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>
>
>



 
Reply With Quote
 
 
 
 
Tony
Guest
Posts: n/a
 
      06-15-2004


Thank you for your help.

There is no such paragragh in the web.config file. Which place i can add
these lines into this file?

"Martin Marinov" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> do you have a web.config file with these lines
>
> <appSettings>
> <add key="PubsString" key="your connectionstring here" />
> </appSettings>
>
> Regards
> Martin
>
>
> "Tony" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Dear All,
> > When I run an example program on the
> >

>

http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
> > ring"))
> > MyCommand = New SqlDataAdapter("select * from Authors",
> > MyConnection)
> > DS = new DataSet()
> > MyCommand.Fill(ds, "Authors")
> > MyDataGrid.DataSource=ds.Tables("Authors").Default View
> > 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>
> >
> >

>
>



 
Reply With Quote
 
Martin Marinov
Guest
Posts: n/a
 
      06-15-2004

your web.config must have such structure

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.web>

.....

</system.web>

<appSettings>

<add key="PubsString" key="your connectionstring here" />

</appSettings>

</configuration>

Regards
Martin


"Tony" <(E-Mail Removed)> wrote in message
news:u0g$(E-Mail Removed)...
>
>
> Thank you for your help.
>
> There is no such paragragh in the web.config file. Which place i can add
> these lines into this file?
>
> "Martin Marinov" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > do you have a web.config file with these lines
> >
> > <appSettings>
> > <add key="PubsString" key="your connectionstring here" />
> > </appSettings>
> >
> > Regards
> > Martin
> >
> >
> > "Tony" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Dear All,
> > > When I run an example program on the
> > >

> >

>

http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
> > > ring"))
> > > MyCommand = New SqlDataAdapter("select * from Authors",
> > > MyConnection)
> > > DS = new DataSet()
> > > MyCommand.Fill(ds, "Authors")
> > > MyDataGrid.DataSource=ds.Tables("Authors").Default View
> > > 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>
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      06-15-2004
Dear Martin,

Thak you for your quick reply.I am sorry for interrupt you again,

I have added the following lines into the web.config file,

<appSettings>
<add key="PubsString" value="Provider='sqloledb';Initial Catalog='Pubs';
uid='v-tleung';pwd='Mynameis@01'">
</add>
</appSettings>

but i recieved the following error:

"Exception Details: System.ArgumentException: Keyword not supported:
'provider'.

Source Error:
Line 11: Dim MyCommand As SqlDataAdapter
Line 12:
Line 13: MyConnection = New
SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings("PubsSt
ring"))
Line 14: MyCommand = New SqlDataAdapter("select * from Authors",
MyConnection)
Line 15:

I have installed Sql Server on my localhost. How can we compose the
ConnectionString. Does this program work well on your side?

"Martin Marinov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> your web.config must have such structure
>
> <?xml version="1.0" encoding="utf-8" ?>
>
> <configuration>
>
> <system.web>
>
> ....
>
> </system.web>
>
> <appSettings>
>
> <add key="PubsString" key="your connectionstring here" />
>
> </appSettings>
>
> </configuration>
>
> Regards
> Martin
>
>
> "Tony" <(E-Mail Removed)> wrote in message
> news:u0g$(E-Mail Removed)...
> >
> >
> > Thank you for your help.
> >
> > There is no such paragragh in the web.config file. Which place i can add
> > these lines into this file?
> >
> > "Martin Marinov" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > do you have a web.config file with these lines
> > >
> > > <appSettings>
> > > <add key="PubsString" key="your connectionstring here" />
> > > </appSettings>
> > >
> > > Regards
> > > Martin
> > >
> > >
> > > "Tony" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > Dear All,
> > > > When I run an example program on the
> > > >
> > >

> >

>

http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
> > > > ring"))
> > > > MyCommand = New SqlDataAdapter("select * from Authors",
> > > > MyConnection)
> > > > DS = new DataSet()
> > > > MyCommand.Fill(ds, "Authors")
> > > > MyDataGrid.DataSource=ds.Tables("Authors").Default View
> > > > 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>
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Martin Marinov
Guest
Posts: n/a
 
      06-15-2004
Well, because of using sql client you can not use the oledb provider
try using this connection string :

workstation id=your_computer_name;packet size=4096;user id=v-tleung;data
source=your_sql_server;persist security info=False;initial catalog=Pubs;
Password=Mynameis@01;

if your sql server is installed locally for data source put : localhost

you can see here all of possible connection strings :
http://www.connectionstrings.com/

Regards
Martin

"Tony" <(E-Mail Removed)> wrote in message
news:uLZ$(E-Mail Removed)...
> Dear Martin,
>
> Thak you for your quick reply.I am sorry for interrupt you again,
>
> I have added the following lines into the web.config file,
>
> <appSettings>
> <add key="PubsString" value="Provider='sqloledb';Initial Catalog='Pubs';
> uid='v-tleung';pwd='Mynameis@01'">
> </add>
> </appSettings>
>
> but i recieved the following error:
>
> "Exception Details: System.ArgumentException: Keyword not supported:
> 'provider'.
>
> Source Error:
> Line 11: Dim MyCommand As SqlDataAdapter
> Line 12:
> Line 13: MyConnection = New
>

SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings("PubsSt
> ring"))
> Line 14: MyCommand = New SqlDataAdapter("select * from Authors",
> MyConnection)
> Line 15:
>
> I have installed Sql Server on my localhost. How can we compose the
> ConnectionString. Does this program work well on your side?
>
> "Martin Marinov" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > your web.config must have such structure
> >
> > <?xml version="1.0" encoding="utf-8" ?>
> >
> > <configuration>
> >
> > <system.web>
> >
> > ....
> >
> > </system.web>
> >
> > <appSettings>
> >
> > <add key="PubsString" key="your connectionstring here" />
> >
> > </appSettings>
> >
> > </configuration>
> >
> > Regards
> > Martin
> >
> >
> > "Tony" <(E-Mail Removed)> wrote in message
> > news:u0g$(E-Mail Removed)...
> > >
> > >
> > > Thank you for your help.
> > >
> > > There is no such paragragh in the web.config file. Which place i can

add
> > > these lines into this file?
> > >
> > > "Martin Marinov" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > do you have a web.config file with these lines
> > > >
> > > > <appSettings>
> > > > <add key="PubsString" key="your connectionstring here" />
> > > > </appSettings>
> > > >
> > > > Regards
> > > > Martin
> > > >
> > > >
> > > > "Tony" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed)...
> > > > > Dear All,
> > > > > When I run an example program on the
> > > > >
> > > >
> > >

> >

>

http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
> > > > > ring"))
> > > > > MyCommand = New SqlDataAdapter("select * from Authors",
> > > > > MyConnection)
> > > > > DS = new DataSet()
> > > > > MyCommand.Fill(ds, "Authors")
> > > > > MyDataGrid.DataSource=ds.Tables("Authors").Default View
> > > > > 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>
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      06-15-2004
Dear Martin,



It works!!



After I used the following connection string:



ˇ°workstation id='sha-tongl-xp1';uid=sa;pwd='';server=localhost;initial
catalog='Pubs'ˇ±



I really appreciated your help. Have a wonderful day!



"Martin Marinov" <(E-Mail Removed)> wrote in message
news:%23NN$(E-Mail Removed)...
> Well, because of using sql client you can not use the oledb provider
> try using this connection string :
>
> workstation id=your_computer_name;packet size=4096;user id=v-tleung;data
> source=your_sql_server;persist security info=False;initial catalog=Pubs;
> Password=Mynameis@01;
>
> if your sql server is installed locally for data source put : localhost
>
> you can see here all of possible connection strings :
> http://www.connectionstrings.com/
>
> Regards
> Martin
>
> "Tony" <(E-Mail Removed)> wrote in message
> news:uLZ$(E-Mail Removed)...
> > Dear Martin,
> >
> > Thak you for your quick reply.I am sorry for interrupt you again,
> >
> > I have added the following lines into the web.config file,
> >
> > <appSettings>
> > <add key="PubsString" value="Provider='sqloledb';Initial

Catalog='Pubs';
> > uid='v-tleung';pwd='Mynameis@01'">
> > </add>
> > </appSettings>
> >
> > but i recieved the following error:
> >
> > "Exception Details: System.ArgumentException: Keyword not supported:
> > 'provider'.
> >
> > Source Error:
> > Line 11: Dim MyCommand As SqlDataAdapter
> > Line 12:
> > Line 13: MyConnection = New
> >

>

SqlConnection(System.Configuration.ConfigurationSe ttings.AppSettings("PubsSt
> > ring"))
> > Line 14: MyCommand = New SqlDataAdapter("select * from Authors",
> > MyConnection)
> > Line 15:
> >
> > I have installed Sql Server on my localhost. How can we compose the
> > ConnectionString. Does this program work well on your side?
> >
> > "Martin Marinov" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > >
> > > your web.config must have such structure
> > >
> > > <?xml version="1.0" encoding="utf-8" ?>
> > >
> > > <configuration>
> > >
> > > <system.web>
> > >
> > > ....
> > >
> > > </system.web>
> > >
> > > <appSettings>
> > >
> > > <add key="PubsString" key="your connectionstring here" />
> > >
> > > </appSettings>
> > >
> > > </configuration>
> > >
> > > Regards
> > > Martin
> > >
> > >
> > > "Tony" <(E-Mail Removed)> wrote in message
> > > news:u0g$(E-Mail Removed)...
> > > >
> > > >
> > > > Thank you for your help.
> > > >
> > > > There is no such paragragh in the web.config file. Which place i can

> add
> > > > these lines into this file?
> > > >
> > > > "Martin Marinov" <(E-Mail Removed)> wrote in message
> > > > news:%(E-Mail Removed)...
> > > > > do you have a web.config file with these lines
> > > > >
> > > > > <appSettings>
> > > > > <add key="PubsString" key="your connectionstring here" />
> > > > > </appSettings>
> > > > >
> > > > > Regards
> > > > > Martin
> > > > >
> > > > >
> > > > > "Tony" <(E-Mail Removed)> wrote in message
> > > > > news:(E-Mail Removed)...
> > > > > > Dear All,
> > > > > > When I run an example program on the
> > > > > >
> > > > >
> > > >
> > >

> >

>

http://www.dotnetjunkies.com/quickst...d1.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.ConfigurationSe ttings.AppSettings("PubsSt
> > > > > > ring"))
> > > > > > MyCommand = New SqlDataAdapter("select * from Authors",
> > > > > > MyConnection)
> > > > > > DS = new DataSet()
> > > > > > MyCommand.Fill(ds, "Authors")
> > > > > > MyDataGrid.DataSource=ds.Tables("Authors").Default View
> > > > > > 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>
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The ConnectionString property has not been initialized. Laura K ASP .Net 12 05-15-2010 05:22 AM
ExecuteReader: Connection property has not been initialized MattB ASP .Net 3 10-04-2007 08:09 AM
2.0: "The ConnectionString property has not been initialized." RAM ASP .Net 0 10-09-2006 01:58 PM
The printing has been stopped and this job has been add to the queu? dejola Computer Support 6 12-30-2005 03:26 AM
ExecuteReader: Connection property has not been initialized. CJM ASP .Net 2 08-17-2004 02:51 PM



Advertisments