Solved

vb.Net Design Time ConnectionString for Devlopment...

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now