[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.net strongly typed dataset and connection string at runtime

Posted on 2009-02-24
3
Medium Priority
?
468 Views
Last Modified: 2013-12-17
I have a stronly typed dataset in a dll.  It currently has a hard coded connection string.  The same dll also has a class I call ApplicationSettings which loads app setting from a config file located on the network.

How can I make my dataset get it's connection string at runtime.  Is there an event for the DS?  
0
Comment
Question by:jackjohnson44
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
graye earned 2000 total points
ID: 23730102
This is a bit complicated, so bare with me...  
Yes, you can (and should) move your hard-coded connection string to the "app.config" file.   However, there is a catch... the designer will put the connection string in the wrong "app.config" file.   It will put it in the app.config file for the DLL (which is totally useless, the DLL files don't look there)
The solution is that you let the designer put the file in the wrong place... then just use Notepad to copy the few lines of XML code from the DLL's config file to paste it into the app.config file of the application (the *.exe file) that consumes the DLL.
Using this technique your Application will load the DLL, and the DLL will be able to use the ApplicationSetting sections of the Application's config file.
0
 

Author Comment

by:jackjohnson44
ID: 23730122
Thanks, but isn't there an easier way by overriding functions on the dataset?

I have clicked by accident before and saw a class with code behind.
I just can't figure out how to do it.
0
 
LVL 41

Expert Comment

by:graye
ID: 23734449
Well, sure... a "write your own" is always an option.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question