Results 1 to 3 of 3

Thread: The ConnectionString property has not been initialized.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    The ConnectionString property has not been initialized.

    I am trying to use a connection string from web.config file for the first time. Here is my code.
    VB Code:
    1. Try
    2.             Dim cmd As String = _
    3.                 ("SELECT [Name], BirthDate, StartDate From " & _
    4.                 "Employees WHERE PayGroup='20' AND Status='A'")
    5.  
    6.             Dim conn As String = _
    7.                 System.Configuration. _
    8.                 ConfigurationManager. _
    9.                 AppSettings("myConString")
    10.  
    11.             Dim myConn As New SqlConnection(conn)
    12.             Dim myCmd As New SqlDataAdapter(cmd, myConn)
    13.             Dim ds As New DataSet
    14.             myCmd.Fill(ds)
    15.             gvEmp.DataSource = ds
    16.             gvEmp.DataBind()
    17.  
    18.         Catch ex As Exception
    19.             Response.Write(ex.Message & "<br>")
    20.         Finally
    21.  
    22.         End Try
    I am getting The ConnectionString property has not been initialized. What am I doing wrong?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: The ConnectionString property has not been initialized.

    Show your web.config code.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Re: The ConnectionString property has not been initialized.

    <connectionStrings>
    <add name="myConString" connectionString="Data Source=myServer;Initial Catalog=Employees;User ID=myUser;Password=mypass"
    providerName="System.Data.SqlClient" />
    </connectionStrings>
    Last edited by FastEddie; Aug 10th, 2006 at 06:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width