Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 09, 2012 03:44 PM by jpuga
May 09, 2012 02:57 PM|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 03:04 PM|LINK
Reference System.Configuration and then you can access it by:
May 09, 2012 03:18 PM|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 03:20 PM|LINK
Ahh...you're on VB.NET:
May 09, 2012 03:44 PM|LINK
Thanks a lot now works......