Solved

vb.Net Design Time ConnectionString for Devlopment...

Posted on 2004-03-30
4
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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 video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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