Connect to the right SQL Server during runtime

K

Ken Jones

Hi all,

I am new to VB.NET and would like to get some help.

I have a VB.NET Windows application that connects to my development
SQLServer during development. I use the VS 2005 designer to create the
DataSet (via Add Data Connection) that points to my development SQL
Server and drag the fields and drop them to my forms and reports.

The problem I have is that the application cannot be deployed since the
code always points back to my development SQL Server.

I tried changing the ConnectionString during application initialization
with the appropriate string that points to the customer's SQL Server,
but the ConnectionString in the My.Settings has Application scope
(read-only), not User scope (read-write). I would like to stay away
from having to supply app.config file.

Another thing I tried is to create another SqlConnection object with
the correct connection string (server name, etc.) and replace the
SqlConnection object during application initialization. That does not
work either because the SqlConnection object that is created in the
wizard-generated code is private. I hate to modify the wizard-generated
code since there is a strong warning on the top that says "Do not
modify".

I would like to know if there is a way to do one of the following from
within the application that I am not aware of:
(1) Modify the connection string.
(2) Make the wizard-generated code use the SqlConnection object
that I create during initialization with the correct connection string.

If the answers to both are 'no', what other ways can I solve this
problem?

It appears that using wizard (designer) is not the right way to develop
applications that can be deployed to customers, even though it helps
you quite a bit during design with it's drag and drop ease onto the
forms and reports. What do you think?

I appreciate any help I can get.

Thanks in advance.
Ken
 
R

rowe_newsgroups

Personally, I don't use the wizard so I can't really help you on how to
use it to edit the connection string and other settings. However, you
shouldn't be afraid to edit the generated code, just back it up first
so if you accidently ruin something you can just restore it. Editing
the code itself will also teach you more about the language than just
using a wizard. If you need any help changing the generated code please
post back and I will try to help you out.

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top