Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub txtusername_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtusername.TextChanged
        username = txtusername.Text
        connect.Open()
        ds.Clear()
        da = New OleDb.OleDbDataAdapter("SELECT * FROM tbluser", connect)
        da.Fill(ds, "tbluser")
        Dim dv As New DataView(ds.Tables("tbluser"))
        dv.RowFilter = "username= '" & username & "'"
        DataGridView1.DataSource = dv
        connect.Close()


    End Sub
Posted

Replace this instead of con.open() and con.Close()

C#
if(con.state==ConnectionState.Closed)
{
con.open();
}

if(con.state==ConnectionState.Open)
{
con.Close();
}



The Error because your Connection is not closed but you are trying to open it.
 
Share this answer
 
DataAdapter automatically opens and closes the connection. No need to explicitly open the connection.

Reference - OleDbDataAdapter Constructor (String, OleDbConnection)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900