Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Help! how do I Configure the DB connection settings during setup?

Last post 05-10-2008 1:38 PM by argoran. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-03-2008 11:05 AM

    • argoran
    • Not Ranked
    • Joined on 04-03-2008
    • United Kingdom
    • New Member
    • Points 35

    Help! how do I Configure the DB connection settings during setup?

     

    Hi, I am a VB.NET beginner and am trying to connect to a backend db ( SQL serverf 2000 ) I have currently hard coded this in my program, but have come to realise that that was not a good idea, instead it would have been better to variablise it somehow and let the admins that will install the application populate the backend server during setup. my setup is an msi setup that I let VS2005 create for me - I have tried using .config files but failed as for some reason I could not see anything in the .config file from within my code or reference it. I see applications every day where during the msi setup ( possibly as a public property ) you can add the db server details which is read from within the code, can someone please assist me or point me to how to do this? Many Thanks in advance. Edit/Delete Message
    • Post Points: 20
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 04-03-2008 5:24 PM In reply to

    • yr
    • Top 500 Contributor
    • Joined on 06-01-2007
    • United States
    • Member
    • Points 380

    Re: Help! how do I Configure the DB connection settings during setup?

    in app.config file   copy below code  and set ur database settings

    <
    connectionStrings>

    <add name="Dbase" connectionString="Data Source= servr name;initial catalog=database; User id=test; Password=test"/>

    </connectionStrings>

    • Post Points: 10
  • 04-04-2008 1:07 PM In reply to

    • argoran
    • Not Ranked
    • Joined on 04-03-2008
    • United Kingdom
    • New Member
    • Points 35

    Re: Help! how do I Configure the DB connection settings during setup?

     how do I reference the app.config from within my code?

    • Post Points: 5
  • 05-10-2008 7:54 AM In reply to

    • shuchirp
    • Not Ranked
    • Joined on 12-08-2007
    • India
    • Junior Member
    • Points 90

    Re: Help! how do I Configure the DB connection settings during setup?

    Hi ,

    if you want to set connectionstring during ur setup,then first of when u make setup  asking about ur connection,save it to registery.When ur application will run.it will read a connection from registery.

    for read and write data to registery use SaveSetting and GetSetting Property.

    in ur application when it will read data from registery and save to ur connection string use following.

    My.Settings.ConnectionStringName=Strconnection

    • Post Points: 10
  • 05-10-2008 8:38 AM In reply to

    Re: Help! how do I Configure the DB connection settings during setup?

    Mr Argoran, See this code. This will connect to database without any parameters. What all you require is Database name. See, When you are going to work with Database, better create your own database.Create Database. When creating database in your hands, pre define with a name and append to Connection string. Well. Any doubts on this are welcome.

    Imports System.Data.SqlClient

    Imports System.Data

    Public Class Form1

    Dim cn As New SqlConnection("Integrated Security=TRUE;Persist Security Info=FALSE;")

    Dim cmd As New SqlCommand

    Dim da As New SqlDataAdapter

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    cn.Open()

    If cn.State = ConnectionState.Open Then

    Button1.Text = "Connected"

    Else

    Button1.Text = "NOT Connected"

    End If

    End Sub

    End Class

    for more information please contact sambariramesh@gmail.com
    • Post Points: 5
  • 05-10-2008 1:38 PM In reply to

    • argoran
    • Not Ranked
    • Joined on 04-03-2008
    • United Kingdom
    • New Member
    • Points 35

    Re: Help! how do I Configure the DB connection settings during setup?

     Thank you I don't know why I didn't think of that even though it's quite obvious and easy to setup -- Many Thanks !!!!!

    • Post Points: 5
Page 1 of 1 (6 items)