473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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;Initial Catalog=AccessMed;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

My connection to the db from aspx file:

string strSQL = "SELECT * FROM Client";

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

SqlDataAdapter myCommand = new SqlDataAdapter(strSQL, 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

Sep 29 '05 #1
3 1450
Use the specific newsgroups for 2005 questions:
http://communities.microsoft.com/new...elcomePage.htm

--
David Portas
SQL Server MVP
--

Sep 29 '05 #2
aspx.cs file. I'm using C# as code behind.

"draku" <jk*****@hotmail.com> wrote in message

My connection to the db from aspx file:

Sep 29 '05 #3
GOT IT!
If anyone ever have the same problem this is the solution:
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrin gs["AMConn"].ConnectionString);

"draku" <jk*****@hotmail.com> wrote in message news:dh**********@inews.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;Initial Catalog=AccessMed;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

My connection to the db from aspx file:

string strSQL = "SELECT * FROM Client";

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

SqlDataAdapter myCommand = new SqlDataAdapter(strSQL, 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

Sep 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.