Saturday, October 24, 2009

Connection Strings in web.config?

I have an web application that I made and put up on a webserver. It pulls data from an access database that I use as a demo database. I am trying to get my connection string set up right to work with my database since it is now on the host server and not my computer. I have my access databse loaded up on my host webserver and and the host company has a page that test the connection to the databse and it tells me the connection string and then displays all the tables in the access database. So it is working proberly. The connection string they game me is below



set testconn=server.createobject(%26quot;adodb.conn...



Set TestRs = Server.CreateObject (%26quot;ADODB.RecordSet%26quot;)



cnstr = %26quot;DSN=DGFMed.demo%26quot;



testconn.Open cnstr



I dont know what my connection string should look like. What I have now is below and is not working



%26lt;add name=%26quot;DemoConnectionString%26quot; connectionString=%26quot;DNS=DGFmed.demo%26quot;



providerName=%26quot;System.Data.OleDb%26quot; /%26gt;



what do I need to change?



Connection Strings in web.config?





You should not be using a DSN on your host unless they have set one up for you (not recommended - DSNs are more frustrating than useful).



The following connection string should work for most situations:



%26quot;Provider = Microsoft.Jet.OLEDB.4.0; Data Source=database.mdb; User Id=usr; Password=pwd%26quot;



The example below is not correct for connecting to a file-based Access data source.



Connection Strings in web.config?



It should be



%26lt;appSettings%26gt;



%26lt;add key=%26quot;myConnString%26quot; value=%26quot;Data Source = serverName; Initial Catalog = database name; Integrated security=SSPI; username= user; password = pwd /%26gt;



%26lt;/appSettings%26gt;



Remember Integrated security SSPI is windows authentication, if its not windows auth, you need to set it to false and just pass in the username and password for the SQL database.



Also google web.config, plenty of good articles especially on 4guysfromRolla



http://aspnet.4guysfromrolla.com/article...

No comments:

Post a Comment

 

Web hosting service Copyright 2008 All Rights Reserved Baby Blog Designed by Ipiet | Web Hosting