at the projct No i have choses it should the the project name on the textbox but did not come out

    Private Sub cbbproject_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbbproject.SelectedIndexChanged

        Dim conn As New System.Data.OleDb.OleDbConnection()
        conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
        If conn.State = ConnectionState.Open Then conn.Close()
        conn.Open()
        Dim sql As String = "Select [Project Name] ProNm From tbl_assignment Where ProjectNo ='" & cbbproject.Items(cbbproject.SelectedIndex) & "'"
        Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
        sqlCom.Connection = conn
        Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
        If sqlReader.HasRows Then
            sqlReader.Read()
            txtpn.Text = (sqlReader.Item("[ProNm]").ToString)
        End If
        sqlReader.Close()
        sqlCom.Dispose()
        conn.Close()

It should be like

 Dim conn As New System.Data.OleDb.OleDbConnection()
        conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
        If conn.State = ConnectionState.Open Then conn.Close()
        conn.Open()
        Dim sql As String = "Select [Project Name] As ProNm From tbl_assignment Where ProjectNo ='" & cbbproject.Items(cbbproject.SelectedIndex) & "'"
        Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
        sqlCom.Connection = conn
        Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
        If sqlReader.HasRows Then
            sqlReader.Read()
            txtpn.Text = (sqlReader.Item("ProNm").ToString)
        End If
        sqlReader.Close()
        sqlCom.Dispose()
        conn.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.