connection string not initialized
(VS 2008 .net 3.5) I'm really confused right now. Someone else created a website that I've been working on. We open the project solution when we work on it because we're using SourceGear Vault so everyone can work on it at the same time. We have different classes we're using and there's a global.asax. When I work on this program, it points to a local location on my computer, yet it's still connected through the network to know who has what checked out and what i can or cannot work on. When I run the program locally, everything works perfectly fine. When I put the application on the web server so I can view the program on our intranet site, I keep getting the connection string has not been initialized error. What's the difference between running it on my machine locally and running it on the web server?
Here's the global file that gets the connection
Code:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Dim JMconnString As String = ConfigurationManager.ConnectionStrings("JMConnectionString").ConnectionString
Dim M2MconnString As String = ConfigurationManager.ConnectionStrings("M2MConnectionString").ConnectionString
DBObj = New DBTools(JMconnString, M2MconnString, "c:")
Application("DBTools") = DBObj
Dim configfile As String = ConfigurationManager.AppSettings("OptionFileLoc")
configfile = Server.MapPath("ConFig/")
configfile = configfile & "ProgramInfo.xml"
ConfigurationManager.AppSettings("OptionFileLoc") = configfile
End Sub
This is the code that's running
Code:
Dim dt As DataTable = QuikShipProduct.GetQSProductTypes
this calls the class that runs this:
Public Shared Function GetQSProductTypes()
Return DBTools.CreateDT("select * from tblQSProductTypes order by ProdTypeID", DBLayer.DBTools.DB.DW)
End Function
Let me know if any code or other information is needed.
Re: connection string not initialized
Code:
ConfigurationManager.ConnectionStrings
This I believe is reading the Web.Config file for the connection string (may be another app.config, not sure how you're app is setup). Check the connection string names and declarations in the ConnectionStrings portion of your config file (if this exists) match on the server and your local machine.
There's a greate freeware file comparison tool called ExamDiff which you can lookup from a searchengine to save time...
Re: connection string not initialized
What do you mean by match them on the local and server machines? How would I do that?
You are right, in the web.config file I have these connection strings:
HTML Code:
<connectionStrings>
<add name="JMConnectionString" connectionString="Data Source=DATA2;Initial Catalog=JobInfo;User ID=123WEB;Password=213bew" providerName="System.Data.SqlClient"/>
<add name="M2MConnectionString" connectionString="Data Source=DATA2;Initial Catalog=DATA01;User ID=123WEB;Password=213bew" providerName="System.Data.SqlClient"/>
</connectionStrings>
Re: connection string not initialized
Well basically I meant just simply check they show the same information there, that was all :)
I wondered whether the web.config file existed at both, and whether all the information - the connection string names and values (database names, logon information in them etc.) in your local computer's web.config file for this site, which is working, is the same as the information in the server version of the web.config file - whether the 2 files are the same.
I guess you could also check whether any double quote or XML tags on these connection string declaration lines are misplaced also, but I imagine that might give a different error.
If you use a file comparison tool, it'd tell you this information pretty easy :) :cool: