Home > Archive > Microsoft SQL Server forum > September 2005 > ASP.NET + SQL 2005









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ASP.NET + SQL 2005
draku

2005-09-29, 1:23 pm

Guys, I have a problem with setting up connection from asp file to MS Sql db.
I'm using Web.Config as the file to setup the connection:
<connectionStrings>

<add name="AMConn" connectionString="Data Source=TWS_WS04;Init
ial Catalog=AccessMed;In
tegrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>



My connection to the db from aspx file:

string strSQL = "SELECT * FROM Client";

SqlConnection myConnection = new SqlConnection(Config
urationManager.AppSettings["AMConn"]);

SqlDataAdapter myCommand = new SqlDataAdapter(strSQ
L, myConnection);

DataSet objDataSet = new DataSet();

myCommand.Fill(objDataSet, "Client");

DataTable objDataTable = objDataSet.Tables["Client"];



And the error message: "The ConnectionString property has not been initialized."

I know that there is a problem with my connection because no matter what I put as AppSettings["ANYTHING I WANT"]); - the error is always the same.

I'm new to asp.net and I would appreciate any help.



Thanks,

Jim

David Portas

2005-09-29, 1:23 pm

Use the specific newsgroups for 2005 questions:
http://communities.microsoft.com/ne...welcomePage.htm

--
David Portas
SQL Server MVP
--

draku

2005-09-29, 1:23 pm

aspx.cs file. I'm using C# as code behind.



"draku" <jkafara@hotmail.com> wrote in message

My connection to the db from aspx file:

draku

2005-09-29, 8:23 pm

GOT IT!
If anyone ever have the same problem this is the solution:
SqlConnection myConnection = new SqlConnection(Config
urationManager.ConnectionStrings["AMConn"].ConnectionString);

"draku" <jkafara@hotmail.com> wrote in message news:dhhakm$dln$1@in
ews.gazeta.pl...
Guys, I have a problem with setting up connection from asp file to MS Sql db.
I'm using Web.Config as the file to setup the connection:
<connectionStrings>

<add name="AMConn" connectionString="Data Source=TWS_WS04;Init
ial Catalog=AccessMed;In
tegrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>



My connection to the db from aspx file:

string strSQL = "SELECT * FROM Client";

SqlConnection myConnection = new SqlConnection(Config
urationManager.AppSettings["AMConn"]);

SqlDataAdapter myCommand = new SqlDataAdapter(strSQ
L, myConnection);

DataSet objDataSet = new DataSet();

myCommand.Fill(objDataSet, "Client");

DataTable objDataTable = objDataSet.Tables["Client"];



And the error message: "The ConnectionString property has not been initialized."

I know that there is a problem with my connection because no matter what I put as AppSettings["ANYTHING I WANT"]); - the error is always the same.

I'm new to asp.net and I would appreciate any help.



Thanks,

Jim

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com