Results 1 to 2 of 2

Thread: the connectionString property has not been initialized

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    4

    the connectionString property has not been initialized

    i face a problem that show connectionString not yet been initialize..
    in web.config i hav these code
    Code:
        <connectionStrings>
            <add name="ConnectionString" connectionString="Provider=SQLOLEDB;Data Source=SERVERNAME;Persist Security Info=True;Password=PASSWORD;User ID=USER;Initial Catalog=Northwind"
                providerName="System.Data.OleDb" />
        </connectionStrings>
    and in my .vb page i hav these
    Code:
    Protected Sub btnAddUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertCategory.Click
            Dim sqlConn As New SqlConnection
            Dim strConnection As String
    
            strConnection = System.Configuration.ConfigurationManager.AppSettings("connectionString")
            sqlConn = New SqlConnection(strConnection)
            sqlConn.Open()
            Try
                Dim command As New SqlCommand("spAddUser", sqlConn)
                command.CommandType = CommandType.StoredProcedure
    
                command.Parameters.AddWithValue("@intUserID", "6")
                command.Parameters.AddWithValue("@ncharname", "Pauly")
                command.Parameters.AddWithValue("@ncharUserName", "Paul")
                command.Parameters.AddWithValue("@intDepartmentID", "1")
                command.Parameters.AddWithValue("@intContactNo", "1235")
    
                command.ExecuteNonQuery()
            Catch ex As Exception
                MsgBox(Err.Description, MsgBoxStyle.Critical)
                Throw
            Finally
                sqlConn.Close()
            End Try
        End Sub
    pls help... thanks..

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: the connectionString property has not been initialized

    Regardless of anything else, that's not a valid connection string for an SqlConnection anyway. As the config says, it's for OleDb, not SqlClient. See www.connectionstrings.com for valid formats.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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