all groups > sql server (alternate) > september 2005 >
You're in the

sql server (alternate)

group:

ASP.NET + SQL 2005


Re: ASP.NET + SQL 2005 David Portas
9/29/2005 11:13:09 AM
sql server (alternate):
Use the specific newsgroups for 2005 questions:
http://communities.microsoft.com/newsgroups/ICP/sqlserver2005/us/welcomePage.htm

--
David Portas
SQL Server MVP
--
ASP.NET + SQL 2005 draku
9/29/2005 2:09:24 PM
Guys, I have a problem with setting up connection from asp file to MS =
Sql db.=20
I'm using Web.Config as the file to setup the connection:
<connectionStrings>

<add name=3D"AMConn" connectionString=3D"Data Source=3DTWS_WS04;Initial =
Catalog=3DAccessMed;Integrated Security=3DTrue"

providerName=3D"System.Data.SqlClient" />

</connectionStrings>



My connection to the db from aspx file:

string strSQL =3D "SELECT * FROM Client";

SqlConnection myConnection =3D new =
SqlConnection(ConfigurationManager.AppSettings["AMConn"]);

SqlDataAdapter myCommand =3D new SqlDataAdapter(strSQL, myConnection);

DataSet objDataSet =3D new DataSet();

myCommand.Fill(objDataSet, "Client");

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



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

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,

Re: ASP.NET + SQL 2005 draku
9/29/2005 2:13:36 PM
aspx.cs file. I'm using C# as code behind.



[quoted text, click to view]
Re: ASP.NET + SQL 2005 draku
9/29/2005 2:29:25 PM
GOT IT!
If anyone ever have the same problem this is the solution:
SqlConnection myConnection =3D new =
SqlConnection(ConfigurationManager.ConnectionStrings["AMConn"].Connection=
String);

[quoted text, click to view]
Guys, I have a problem with setting up connection from asp file to MS =
Sql db.=20
I'm using Web.Config as the file to setup the connection:
<connectionStrings>

<add name=3D"AMConn" connectionString=3D"Data =
Source=3DTWS_WS04;Initial Catalog=3DAccessMed;Integrated =
Security=3DTrue"

providerName=3D"System.Data.SqlClient" />

</connectionStrings>



My connection to the db from aspx file:

string strSQL =3D "SELECT * FROM Client";

SqlConnection myConnection =3D new =
SqlConnection(ConfigurationManager.AppSettings["AMConn"]);

SqlDataAdapter myCommand =3D new SqlDataAdapter(strSQL, myConnection);

DataSet objDataSet =3D new DataSet();

myCommand.Fill(objDataSet, "Client");

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



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

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,

AddThis Social Bookmark Button