By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
do you have a web.config file with these lines

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

Regards
Martin
"Tony" <li*********@hotmail.com> wrote in message
news:eY**************@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>

Nov 18 '05 #2

P: n/a


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" <me********@mecrossroad.bg> wrote in message
news:%2***************@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" <li*********@hotmail.com> wrote in message
news:eY**************@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>


Nov 18 '05 #3

P: n/a

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" <li*********@hotmail.com> wrote in message
news:u0**************@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" <me********@mecrossroad.bg> wrote in message
news:%2***************@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" <li*********@hotmail.com> wrote in message
news:eY**************@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>



Nov 18 '05 #4

P: n/a
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" <me********@mecrossroad.bg> wrote in message
news:O8**************@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" <li*********@hotmail.com> wrote in message
news:u0**************@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" <me********@mecrossroad.bg> wrote in message
news:%2***************@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" <li*********@hotmail.com> wrote in message
news:eY**************@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>
>
>



Nov 18 '05 #5

P: n/a
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" <li*********@hotmail.com> wrote in message
news:uL**************@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" <me********@mecrossroad.bg> wrote in message
news:O8**************@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" <li*********@hotmail.com> wrote in message
news:u0**************@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" <me********@mecrossroad.bg> wrote in message
news:%2***************@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" <li*********@hotmail.com> wrote in message
> news:eY**************@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>
> >
> >
>
>



Nov 18 '05 #6

P: n/a
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" <me********@mecrossroad.bg> wrote in message
news:%2****************@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" <li*********@hotmail.com> wrote in message
news:uL**************@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" <me********@mecrossroad.bg> wrote in message
news:O8**************@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" <li*********@hotmail.com> wrote in message
news:u0**************@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" <me********@mecrossroad.bg> wrote in message
> news:%2***************@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" <li*********@hotmail.com> wrote in message
> > news:eY**************@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>
> > >
> > >
> >
> >
>
>



Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.