Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / September 2005

Tip: Looking for answers? Try searching our database.

database connection for deployment

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HollyylloH - 16 Sep 2005 20:33 GMT
I have a VisualStudio .NET VB form that connects via ADO .NET to a SQL
database. I have created the application and everything works well on my
development computer. I need to know how and where to write the code so that
when the application is taken to any LAN it can be setup with the appropriate
connection string et all.

Each setup location will have a computer running SQL with the database
installed and several client machines with the application installed.

I am sure this is a simple task. I hope someone can help me soon with this.
Let me know if I have left out any information needed.

Thank you in advance
Oscar_Uio - 19 Sep 2005 12:02 GMT
Hi, HollyylloH

one way to deploy a conection string is to write it in a configuration
file.  So in your code in your conection you can read from the
configuration file your conection string.

When you deploy your application you only change in the configuration
file the conection string and the application still working fine

Greetings,

Oscar R. Espinosa
HollyylloH - 20 Sep 2005 02:44 GMT
Oscar,

Thank you. I am not sure how to go about this. Could you help me get started
in the right direction?

> Hi, HollyylloH
>
[quoted text clipped - 8 lines]
>
> Oscar R. Espinosa
HollyylloH - 20 Sep 2005 05:34 GMT
I had tried to set the configuration string within the Windows Form Designer
area and only succeeded in creating more problems. I put this same code
behind a load button and that took care of this issue for me.

Dim sServer as sting
Dim sWorkstation as string
sServer = Me.ServerName.Text
sWorkstation = Me.Workstation.Text
Me.SqlConnection1.ConnectionString = "workstation id=" + sWorkstation +
";packet size=4096;integrated security=SSPI;data source=" + sServer +
";persist security info=False;initial catalog=SigVerify"
     
If anyone knows a problem with assigning a Server in this manner let me
know; otherwise this seems to work just fine.

> Oscar,
>
[quoted text clipped - 13 lines]
> >
> > Oscar R. Espinosa
Oscar_Uio - 21 Sep 2005 10:36 GMT
Hi HollyylloH,

In your code you need use the Namespace System.Configuration

Me.SqlConnection1.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings("ConnectionString").ToString

that line, will read from your configuration file the connection
string. Then when you need to modify your conection string you have to
modify your configuration file.

This a example of a configuration file, that is a xml file. In your
project you have to add a configuration file , in the solution explorer
, add new file --> select application configuration file. This will
create a new file named app.config, in this file you must create a new
tag on this way.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- Configuración SQL Server -->
<add key="ConnectionString" value="Integrated Security=False;User
ID=User;Password=pass;Initial Catalog=DatabaseName;Data
Source=Server"/>
</appSettings>
</configuration>

I hope it can be helpfull to you.

Regards,
Oscar R. Espinosa

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.