Solved

vb.Net Design Time ConnectionString for Devlopment...

Posted on 2004-03-30
4
362 Views
Last Modified: 2012-06-22
Upon starting the application we've developed we prompt the user for the database username/login, with this, we build a connection string and store it in a variable for later use.

That works fine at runtime, since the connection string variable is populated, and any code can use it.

The problem arises if we attempt to use the designers when building windows.  How can I use a design time connection object and give it a connectionstring, when I don't know what the username and password are at design time...

Basically, is there a way to assign the connection object a temporary connectionstring property during design mode that doesn't apply at runtime?

If not, all the designers are useless because storing a connectionstring with a username and password in code is very insecure...
0
Comment
Question by:Gibble
4 Comments
 
LVL 9

Accepted Solution

by:
malharone earned 125 total points
ID: 10718758
that's why i think the .net designers are evil and will make a bad programmer out of you!
try avoiding using those wizards. the connection property once set can not be altered.

refer to MSDN help .. "The ConnectionString property can be set only when the connection is closed. Many of the connection string values have corresponding read-only properties."

basically, on the start of the program you'll have to close your connection and re-instantiate the sql connection object.

hope this helps.

- malhar
0
 
LVL 9

Assisted Solution

by:msdixon
msdixon earned 125 total points
ID: 10719161
what i do when i'm writing prototypes (or something throw-away so i can use the rapid development features of all the design time controls) is create a connection using windows authentication. then in my code, i can read the connection string out from the config file. this works if you put it just after the .net created code call to InitializeComponent() which is in the constructor.

            public MainForm()
            {
                  InitializeComponent();
                  // set connection string here...
            }

0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

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