Start New Discussion within our Software Development Community

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.

the error is here: line 20

Line 18: cn.ConnectionString = connectionInfo
Line 19: If cn.State = ConnectionState.Closed Then
Line 20: cn.Open()
Line 21: End If
Line 22: Dim da As New SqlDataAdapter("select c_name from country order by c_name ", cn)

how can i solve this problem? thanks

If cn.State = ConnectionState.Closed Then
again u need to initilize the connection like cn=new Sqlconnection and cn.connectionstring=connectionInfo

is it in line 20 or what? thanks for your response.. sorry my lack of knowledge. i'm really new. thanks

hera i post the full coding

Imports System.Data
Imports System.Data.SqlClient
Partial Class login
    Inherits System.Web.UI.Page

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    End Sub

    Protected Sub BtnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
        'validate player

        If TxtEmailID.Text.Trim = "" Then
            ClsMain.CreateMessageAlert(Me, "Enter email id.", "123")
            Exit Sub
        End If

        If TxtPassword.Text.Trim = "" Then
            ClsMain.CreateMessageAlert(Me, "Enter password.", "123")
            Exit Sub
        End If

        Dim connectionInfo As String
        connectionInfo = ConfigurationManager.AppSettings("echess")
        Dim cn As New SqlConnection()
        cn.ConnectionString = connectionInfo
        If cn.State = ConnectionState.Closed Then
        End If

        Dim da As New SqlDataAdapter("select * from eg_player where pl_email_address='" & TxtEmailID.Text & "' and pl_password='" & TxtPassword.Text & "'", cn)
        Dim dt As New DataTable()
        If dt.Rows.Count = 1 Then
            If dt.Rows(0)("pl_is_validated") = 0 Then
                ClsMain.CreateMessageAlert(Me, "Can not login, Your membership is not approved by the Admin.", "123")
                Exit Sub
            End If

            Session("mem_id") = dt.Rows(0)("pl_id").ToString()
            Session("mem_name") = dt.Rows(0)("pl_real_name").ToString()
            Session("mem_email_id") = dt.Rows(0)("pl_email_address").ToString()

            If Session("ret_url") = "" Then

            End If


            ClsMain.CreateMessageAlert(Me, "Can not login, Inavlid email id/password.", "123")

        End If

    End Sub
End Class

You have

connectionInfo = ConfigurationManager.AppSettings("echess")

but I still don't know what the value of connectionInfo is. I need to know the actual contents of ConfigurationManager.AppSettings("echess") to see if it is a valid connection string.

sorry if this sound stupid. where can i get the value. is it from web config file?

You can go to Project -> Properties -> Settings

Or you can set a breakpoint just after

connectionInfo = ConfigurationManager.AppSettings("echess")

or you can add the following line after that


after go to Project -> Properties -> Settings, where can i get it? thanks

This question has already been answered. Start a new discussion instead.