By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,089 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,089 IT Pros & Developers. It's quick & easy.

Connect to the right SQL Server during runtime

P: n/a
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

Oct 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Ken Jones wrote:
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
Oct 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.