VWD 2005 Express. Visual Basic. Sql Server 2005. I am trying to establish a connection to a SQL database. The connection (and all other database reads and writes) work fine in debug and in "view in browser" from VWD. I am running the VWD on the same server that hosts the site. When on my server (Windows 2003 Server) under IIS, the connection attempt times out.
Below is the code that is failing (only on the server when deployed):
PrivateSharedSub OpenConn(ByVal cmdAs SqlCommand,ByVal SuccessAsBoolean)
Dim connAsNew SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("GoodNews_IntranetConnectionString").ToString)
'The connection string resolves to ("Data Source=HQSERVER\HQSERVER;Initial Catalog=GoodNews_Intranet;Integrated Security=True"
Try
conn.Open()
cmd.Connection = conn
Success =True
Catch exAs ExceptionSuccess =False
EndTry
EndSub
It would be great if you could post the error message that you are getting.
And in a hosted environment, it is advisable to protect your database by providing a username and password.
|||That may be the ticket. The database does require windows authentication, so how may I make the connection (in vb code) providing a username and password? Perhaps when I am in debug, the sql calls use my windows login, however, when on the server, there is not password being passed?
|||Please visitwww.connectionstrings.com to know the syntax for creating a connection string for your backend with user name and password.
If you think, this resolves your problem, please mark the post as "Answer". by this way we all know your issue is resolved
|||Thank you. I found the answer on the page. I put the User Id and Password in the web.config file where the connection is defined. How can I ensure that this will not be readable when the web site is deployed?
|||It won't be readable to a normal user, but for added security, if its not already in web.confing, then put it there. You can then use encryption to encrypt the connectionstring section (which is much easier than it sounds).
This might help:
http://msdn2.microsoft.com/en-us/library/dx0f3cf2.aspx
|||WEB.CONFIG file is a secure one. No one can read that file outside of your application. In other words, web.config can only be read by the pages within application.
every body uses the web.config to store connection strings and is safe so far.
read the following article to know more about web.config.
http://www.aspdev.org/articles/web.config/
also, please do not forget to mark my post as answer so that we will know for sure that your issue has been resolved.
No comments:
Post a Comment