Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized." (http://www.velocityreviews.com/forums/t80508-asp-net-error-exception-details-system-invalidoperationexception-the-connectionstring-property-has-not-been-initialized.html)

Tony 06-15-2004 06:48 AM

ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."
 
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>
<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"
EnableViewState="false"
/>
</body>
</html>



Martin Marinov 06-15-2004 07:13 AM

Re: ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."
 
do you have a web.config file with these lines

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

Regards
Martin


"Tony" <lianghf2000@hotmail.com> wrote in message
news:eYSKUTqUEHA.1036@TK2MSFTNGP12.phx.gbl...
> 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>
> <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"
> EnableViewState="false"
> />
> </body>
> </html>
>
>




Tony 06-15-2004 07:41 AM

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


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" <memmarinov@mecrossroad.bg> wrote in message
news:%23dc56gqUEHA.220@TK2MSFTNGP10.phx.gbl...
> do you have a web.config file with these lines
>
> <appSettings>
> <add key="PubsString" key="your connectionstring here" />
> </appSettings>
>
> Regards
> Martin
>
>
> "Tony" <lianghf2000@hotmail.com> wrote in message
> news:eYSKUTqUEHA.1036@TK2MSFTNGP12.phx.gbl...
> > 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>
> > <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"
> > EnableViewState="false"
> > />
> > </body>
> > </html>
> >
> >

>
>




Martin Marinov 06-15-2004 07:49 AM

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

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" <lianghf2000@hotmail.com> wrote in message
news:u0g$owqUEHA.3012@tk2msftngp13.phx.gbl...
>
>
> 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" <memmarinov@mecrossroad.bg> wrote in message
> news:%23dc56gqUEHA.220@TK2MSFTNGP10.phx.gbl...
> > do you have a web.config file with these lines
> >
> > <appSettings>
> > <add key="PubsString" key="your connectionstring here" />
> > </appSettings>
> >
> > Regards
> > Martin
> >
> >
> > "Tony" <lianghf2000@hotmail.com> wrote in message
> > news:eYSKUTqUEHA.1036@TK2MSFTNGP12.phx.gbl...
> > > 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>
> > > <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"
> > > EnableViewState="false"
> > > />
> > > </body>
> > > </html>
> > >
> > >

> >
> >

>
>




Tony 06-15-2004 08:30 AM

Re: ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."
 
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" <memmarinov@mecrossroad.bg> wrote in message
news:O8z2H1qUEHA.3988@tk2msftngp13.phx.gbl...
>
> 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" <lianghf2000@hotmail.com> wrote in message
> news:u0g$owqUEHA.3012@tk2msftngp13.phx.gbl...
> >
> >
> > 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" <memmarinov@mecrossroad.bg> wrote in message
> > news:%23dc56gqUEHA.220@TK2MSFTNGP10.phx.gbl...
> > > do you have a web.config file with these lines
> > >
> > > <appSettings>
> > > <add key="PubsString" key="your connectionstring here" />
> > > </appSettings>
> > >
> > > Regards
> > > Martin
> > >
> > >
> > > "Tony" <lianghf2000@hotmail.com> wrote in message
> > > news:eYSKUTqUEHA.1036@TK2MSFTNGP12.phx.gbl...
> > > > 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>
> > > > <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"
> > > > EnableViewState="false"
> > > > />
> > > > </body>
> > > > </html>
> > > >
> > > >
> > >
> > >

> >
> >

>
>




Martin Marinov 06-15-2004 08:40 AM

Re: ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."
 
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" <lianghf2000@hotmail.com> wrote in message
news:uLZ$EMrUEHA.2944@tk2msftngp13.phx.gbl...
> 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" <memmarinov@mecrossroad.bg> wrote in message
> news:O8z2H1qUEHA.3988@tk2msftngp13.phx.gbl...
> >
> > 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" <lianghf2000@hotmail.com> wrote in message
> > news:u0g$owqUEHA.3012@tk2msftngp13.phx.gbl...
> > >
> > >
> > > 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" <memmarinov@mecrossroad.bg> wrote in message
> > > news:%23dc56gqUEHA.220@TK2MSFTNGP10.phx.gbl...
> > > > do you have a web.config file with these lines
> > > >
> > > > <appSettings>
> > > > <add key="PubsString" key="your connectionstring here" />
> > > > </appSettings>
> > > >
> > > > Regards
> > > > Martin
> > > >
> > > >
> > > > "Tony" <lianghf2000@hotmail.com> wrote in message
> > > > news:eYSKUTqUEHA.1036@TK2MSFTNGP12.phx.gbl...
> > > > > 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>
> > > > > <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"
> > > > > EnableViewState="false"
> > > > > />
> > > > > </body>
> > > > > </html>
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>




Tony 06-15-2004 09:27 AM

Re: ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized."
 
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" <memmarinov@mecrossroad.bg> wrote in message
news:%23NN$WRrUEHA.4048@TK2MSFTNGP12.phx.gbl...
> 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" <lianghf2000@hotmail.com> wrote in message
> news:uLZ$EMrUEHA.2944@tk2msftngp13.phx.gbl...
> > 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" <memmarinov@mecrossroad.bg> wrote in message
> > news:O8z2H1qUEHA.3988@tk2msftngp13.phx.gbl...
> > >
> > > 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" <lianghf2000@hotmail.com> wrote in message
> > > news:u0g$owqUEHA.3012@tk2msftngp13.phx.gbl...
> > > >
> > > >
> > > > 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" <memmarinov@mecrossroad.bg> wrote in message
> > > > news:%23dc56gqUEHA.220@TK2MSFTNGP10.phx.gbl...
> > > > > do you have a web.config file with these lines
> > > > >
> > > > > <appSettings>
> > > > > <add key="PubsString" key="your connectionstring here" />
> > > > > </appSettings>
> > > > >
> > > > > Regards
> > > > > Martin
> > > > >
> > > > >
> > > > > "Tony" <lianghf2000@hotmail.com> wrote in message
> > > > > news:eYSKUTqUEHA.1036@TK2MSFTNGP12.phx.gbl...
> > > > > > 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>
> > > > > > <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"
> > > > > > EnableViewState="false"
> > > > > > />
> > > > > > </body>
> > > > > > </html>
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>





All times are GMT. The time now is 05:08 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.