Solved

bound datagridview, c#

Posted on 2014-03-11
8
355 Views
Last Modified: 2014-03-28
I have a Windows form with a bound Datagridview, and it's binding source says that the data source is "_783DataSet".  This, of course, comes from my development machine.

How does this data source know its log on information?  How can I change this at run time to point to a specific server/database on the client's machine?

Thank you.
0
Comment
Question by:g_johnson
  • 4
  • 4
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39921805
It should be in your app.config file, under the <connectionStrings> element.

e.g.

http://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx
0
 
LVL 4

Author Comment

by:g_johnson
ID: 39921897
Does it just pick that up automatically, then?  Do I just deploy it with the application, change the connection info, and it will work?  Or do I have to read it and apply it at run time in some manner?

I never use app.config, as I have developed my own DLL for configuration purposes.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39921920
Yes, the config file should be read automagically by the classes associated with your data access. When you set up all of the binding source stuff, there should have been a prompt that asked if you wanted to save the connection string. It's been a while since I've worked with those components, but if memory serves, I think you need to specify that you want to save the connection string info; otherwise it doesn't get put into your config file.

The app.config file is just an XML file, so you can open it up in a text editor and edit the connection string for the various environments. If you are working on a console application (or WinForms application), then you might look into SlowCheetah and XML conig transforms. These allow you to specify a transform file for each of your deployment environments. These transforms modify the base app.config with the values specified in the transform as you switch between deployment configurations.

If this is a web application, then the SlowCheetah-like functionality is already built in to the project--no need to install SlowCheetah. You simply right-click the base web.config file and select "Add Transform".
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 4

Author Comment

by:g_johnson
ID: 39923459
I'm sorry, but I'm very confused.  My solution has 4 projects, two executables (Windows Form apps) and two DLLs.  On the client workstation they all live together.  3 of the projects have an app.config file with them, so if I were using them, I wouldn't know how to sort that out.

However, in this case, I only delivered the one I need, and I changed the server and database names in that file.  Nonetheless, the executable does not seem to be reading it and the connection is not working.

I noticed that my project has 9 Messages, as follows:
Cound not find schema information for the element "supportedRuntime"
This is repeated for version,sku,applicationSettings,MyProjectName.Properites.Settings,setting,name,serializeAs, and value.

I have no idea what these messages are telling me.

Bottom line is that the DataSet is trying to connect to my development database and I don't know how to change that.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39923478
3 of the projects have an app.config file with them, so if I were using them, I wouldn't know how to sort that out.
The configs that matter are the ones belonging to the executables--DLL configs are not used by the configuration subsystem (by default). Does the executable(s)'s configuration file have the new database information? If not, and short of that, the only other thing I could think to suggest would be to do a search within your project's code for the old connection string. It may be hard-coded based on your responses in the dialogs that originally set up the DataSets.
0
 
LVL 4

Author Comment

by:g_johnson
ID: 39934160
I am unable to make this work.  I have removed all components and started from scratch and am still not able to get it to recognize the app.config.  One final question, though.  If I have two or more executables in the same destination folder, won't the config files both me named app.config?  How is that possible?

Like I said.  I'm very confused!  :-)
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39934194
No. app.config files get renamed during the build process to [ExecutableName].exe.config. Having both in the same output folder should be of no consequence.

When you initially set up the binding source and all of the other pieces, do you see a connection string get output to the app.config file?
0
 
LVL 4

Author Comment

by:g_johnson
ID: 39934203
I'm going to try one more time and watch what happens.  I believe I have a "clear" app.config right now so I can see what's going on.  That renaming you just mentoined might clear this up for me.  I think I was looking (utlimately) at the wrong thing.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn on intranet settings 1 56
use of unassigned local variable 'id' 6 38
MediaHelp 4 23
VS2013 publish C# application Created folder -- where is it??? 10 15
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

772 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