|
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
|
|
|
| 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
| |
|
|
|
| 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:
| |
|
| 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
|
|
|
|
|