473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to change database when deploying application

I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry

Mar 21 '07 #1
7 2500
Perhaps you should put it as User Setting and then build a small form to
allow users to change db settings.
"harry" <no@spam.thankswrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry

Mar 21 '07 #2
VJ
You could also keep it a local xml file or something and read it..

VJ

"harry" <no@spam.thankswrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry

Mar 21 '07 #3

I know what the end users database is called and would prefer to avoid
additional work for user.

I would prefer to set dynamically when loading application.

I guess this is a common scenario and also guess one uses an XML file
deployed with the app.

Having used the designer to set the Connection string, and then built my
DataSet (again using designer) around that connection string I wonder why
the settings are ReadOnly when it's an obvious scenario for many developers.
I guess there's an obvious solution - one that I have yet to find.

Any other suggestions please ?
"Penelope Dramas" <penelopeDOTdramasATpro-transportDOTcomwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Perhaps you should put it as User Setting and then build a small form to
allow users to change db settings.
"harry" <no@spam.thankswrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry


Mar 21 '07 #4

Sure a local XML file would be fine.

I guess I need to change the DataSet.DataSource as the program loads, but
not sure how at the moment.

Having already used the designer to create the connection and DataSet, how
do I go about doing this?

Would you know of a URL showing how do do this?

This must be a common scenario.
"VJ" <no***********@yahoo.comwrote in message
news:ev**************@TK2MSFTNGP04.phx.gbl...
You could also keep it a local xml file or something and read it..

VJ

"harry" <no@spam.thankswrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry


Mar 22 '07 #5
"harry" <no@spam.thankswrote in news:#oexeMAbHHA.1388
@TK2MSFTNGP05.phx.gbl:
Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?
I wish VS.NET had a way to inject deployment App.config keys... that would
solve this problem right? :-)
Mar 22 '07 #6
Hi Harry,

data in the app.config isn't readonly at all! It can be accessed through the
configurationmanager-class (but not by my.settings, that's right). Below you
find code I use to set the connection-string at runtime. Be aware of the
fact, that you can use more than one connectionstring in your config, hence
the SectName.

Public Shared Sub SetConnectString(ByVal SectName As String, ByVal
ConnectString As String, ByVal encrypt As Boolean)
Dim settings As New ConnectionStringSettings
settings.Name = SectName
settings.ConnectionString = ConnectString

Dim config As Configuration
config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None)
config.ConnectionStrings.ConnectionStrings.Remove( SectName)
config.ConnectionStrings.ConnectionStrings.Add(set tings)
If encrypt Then

config.ConnectionStrings.SectionInformation.Protec tSection(Nothing)
End If
config.Save()
End Sub
HTH

Volker

"harry" wrote:
I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry

Mar 22 '07 #7

Great.

Thanks for your help and saving me a heap of time.

Regards
Harry
"VolkerS" <Vo*****@discussions.microsoft.comwrote in message
news:B3**********************************@microsof t.com...
Hi Harry,

data in the app.config isn't readonly at all! It can be accessed through
the
configurationmanager-class (but not by my.settings, that's right). Below
you
find code I use to set the connection-string at runtime. Be aware of the
fact, that you can use more than one connectionstring in your config,
hence
the SectName.

Public Shared Sub SetConnectString(ByVal SectName As String, ByVal
ConnectString As String, ByVal encrypt As Boolean)
Dim settings As New ConnectionStringSettings
settings.Name = SectName
settings.ConnectionString = ConnectString

Dim config As Configuration
config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None)
config.ConnectionStrings.ConnectionStrings.Remove( SectName)
config.ConnectionStrings.ConnectionStrings.Add(set tings)
If encrypt Then

config.ConnectionStrings.SectionInformation.Protec tSection(Nothing)
End If
config.Save()
End Sub
HTH

Volker

"harry" wrote:
>I've set my database connection as an Application.Setting using the
designer.

Since Application.Settings are read only, how do I change the connection
properties when deploying to another machine ?

Thanks
Harry


Mar 22 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: pcPirate | last post by:
Hi, I'm currently writing an application using C#. However, to access and update a database, I must only use rdo (due to a certain reason). I heard I can use the VB6 to make the function of...
1
by: K Meyer | last post by:
Everything in the deployment works fine with the exception of the address of the database also deployed on the remote server. The string address is found under "oledbconnection" in the ".......
2
by: Bennett Haselton | last post by:
When you create a C# Web Application project, you have to specify at project creation time the URL you want to publish the project to. Is there any way in the IDE to change the server that the...
5
by: sling blade | last post by:
I have developled my first major app and i am trying to deploy it in to a host server for publication. However the app tries to use the physical path used during development. Is the path...
3
by: route_coder | last post by:
I am using access database to create a crystal report in VB.NET Everything works fine when I run on my machine. But when I am deploying it other windows machines. It is asking for database server...
3
by: Ben | last post by:
Hi all I have made a vb.net windows app that works great in design. But after deploying the app on the same design computer (my own) the app can not find any of the two databases it needs to...
4
by: Collin Peters | last post by:
I have searched the Internet... but haven't found much relating to this. I am wondering on what the best practices are for migrating a developmemnt database to a release database. Here is the...
3
by: pooba53 | last post by:
I have a VB .NET 2003 application that communicates with an Access db. I am deploying the application using the Wizard that creates an install package and it IS properly grabbing the Access db and...
2
by: Gilbert Tordeur | last post by:
Hello, It is about a VB2008 intranet application. It uses a SQL Server database. The ConnectionString is defined in the connectionStrings section of the web.config file. This application uses...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.