Solved

vb.Net Design Time ConnectionString for Devlopment...

Posted on 2004-03-30
4
361 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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

770 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