Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing database source and how it affects data source objects-

Status
Not open for further replies.

treviboy

Programmer
Dec 18, 2006
70
US
hi,

I am working on trying to figure out why I cannot connect to my database after changing the connectionstring in web.config. If I could change it successfully, does that mean that the data source objects I had defined based on a different database (same tables but different database name and location) will be regenerated based on the changes in the web.config file? Or would I have to recreate them, basing them on a new database? Sorry for asking what seems simple for most, but I have to ask.
Thanks.
 
It depends on how you created them. When you created the data source, did you point them at the connection string in the web.config file? Can you provide an example of what your data sources look like?


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
YOu will have to regenerate the datasource and objects attached to thme
 
When I try to look at the configuration of some of the datasets I have created, it tells me something like
"Configure TableAdapter Students failed. Unable to find connection 'TESTSUB0202BConnectionString' for object
'Web.config'. The connection string could not be found in application settings, or the data provider associated with the connection string could not be loaded.'

-Yesterday I tried adding a new database to my project, but I noticed that I didn't get prompted for the "server" name, so I have a new connection string ( for my database on the server) like this:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=S:\Personnel\Substitute\SubstituteFE.mdb

Shouldn't it be including the server name instead of "s" ?
 
Ok. I tried to "reconfigure" my data source object,but it's giving me the error that I mentioned above - "unable to find connection string..." I have no idea what to do other than start over from the very beginning because I can't point to a different database.
 
If you are going to use a data source object, you should tell it to use the connection string from your web.config file e.g.
Code:
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnection%>" >
           .... 
        </asp:SqlDataSource>
This way, it isn't mapped directly and when you publish the site, you can just change the connection string.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
I can't do that because it gives me error messages. Where is your code that you displayed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top