Solved

vb.Net Design Time ConnectionString for Devlopment...

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

18 Experts available now in Live!

Get 1:1 Help Now