Last post May 09, 2012 11:44 AM by jpuga
May 09, 2012 10:57 AM|jpuga|LINK
my web.config connection string is:
connectionString="Data Source=server\instance;Initial Catalog=Databasename.mdf;User ID=User;Password=password"
but I have been using on my asp.net code the following format to create manually a connection string by code
Dim con As SqlConnection
Dim cmd As SqlCommand
con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dayabasename.mdf;Integrated Security=True;User Instance=True")
cmd = New SqlCommand("dbo.AddPMUpdate", con)
cmd.CommandType = CommandType.StoredProcedure
TBTitle.Text = ""
TBDescription.Text = ""
Catch ex As Exception
LBMessage.Text = ex.Message
now my application has been published, and I got and erroe in each page that I created a manual connection string by code
I would appreciate if you show me how to read the connection string from my web.config to my code.
Thanks in advance, your help will be appreciated....!!!!
May 09, 2012 11:04 AM|HeartattacK|LINK
Reference System.Configuration and then you can access it by:
May 09, 2012 11:18 AM|jpuga|LINK
I tried with this format
String Con = ConfigurationManager.ConnectionStrings["Conectionstring"].ConnectionStrings
but I got and errorstring is a class type and cannot be used as an expression
what do you think??
May 09, 2012 11:20 AM|HeartattacK|LINK
Ahh...you're on VB.NET:
May 09, 2012 11:44 AM|jpuga|LINK
Thanks a lot now works......