jch
Mon Jan 10 02:26:28 CST 2005
The line ConfigurationSettings.AppSettings("ConnectionString") will not work
with the config file you posted. Are you using this line of code? If yes,
then your config file should look like this:
<appSettings>
<add key="ConnectionString" value="..." />
</appSetting>
Or have you defined a configSection for reading the connection string? In
any case, I don't think you are reading the connection string correctly from
the config file, so you should do some debugging trying to find out what the
problem is.
Regards, Jakob.
"Devante" wrote:
> Hi Jakob
>
> I have created a web.config file and it does have the following info in it:
>
> <configuration xmlns="
http://schemas.microsoft.com/.NetConfiguration/v2.0">
>
> <appSettings />
> <connectionStrings>
> <add name="AppConnectionString1"
> connectionString="Server=DCKUEPERS-01;Integrated
> Security=True;Database=WebDev"
> providerName="System.Data.SqlClient" />
> </connectionStrings>
>
>
>
> But for some reason its still not working what am I doing wrong?
> Thank you,
>
> Devante
>
> "Jakob Christensen" wrote:
>
> > Sounds like you did not specify a connection string when creating your
> > SqlConnection object. If you copied the code from the link that you
> > specified then you have a line of code looking like this:
> >
> > Dim myConnection As New
> > SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
> >
> > This indicates that whoever wrote the code put the connection string in the
> > appSettings section of the web.config file. If you did not do this then
> > ConfigurationSettings.AppSettings("ConnectionString") returns null and the
> > SqlConnection object does not know which database to connect to. So you have
> > to specify your own connection string instead.
> >
> > HTH, Jakob.
> >
> >
> > "Devante" wrote:
> >
> > > Hi,
> > >
> > > I am fairly new to ASP.NET and have been working on a web form that will
> > > allow a user to upload images to a database. I have found a sample web form
> > > that I have been trying to get working, and the web form loads up fine but
> > > upon submitting the image, it comes with the following error:
> > >
> > > 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 129: Try
> > > Line 130:
> > > Line 131: myConnection.Open()
> > > Line 132:
> > > Line 133:
> > > myCommand.ExecuteNonQuery()
> > >
> > > I found this script from the following website
> > >
http://aspalliance.com/articleViewer.aspx?aId=138&pId=
> > >
> > > Can anyone please help I am completely lost as to how to correct this problem.
> > > I am using Visual Studio 2005 beta 1, IIS 6.0, .NET version 2.0.40607 and
> > > SQL Server 2000.
> > >
> > > Any help would be greatly appreciated.
> > >
> > > Thank,
> > >
> > > Devante