Hello Gurus,
Hope you can help me with my problem.
I'm getting an error "There is already an open Datareader associated with this command which must be closed first"
I have my below code.
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
can someone help me with this? Thanks in advance!
	
		
			
		
		
	
				
			Hope you can help me with my problem.
I'm getting an error "There is already an open Datareader associated with this command which must be closed first"
I have my below code.
			
				VB.NET:
			
		
		
		Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        Try
            If txtUsername.Text = "" Then
                MsgBox("Please enter your username.")
                txtUsername.Select()
            ElseIf txtPassword.Text = "" Then
                MsgBox("Please enter your password.")
                txtPassword.Select()
            Else
                Dim SqlQuery As String = "INSERT INTO users (Username,[Password]) VALUES ('" & txtUsername.Text & "', '" & txtPassword.Text & "')"
                Dim SqlCommand As New OleDbCommand
                Dim dbRdr As OleDbDataReader
                With SqlCommand
                    .CommandText = "SELECT count(*) FROM users WHERE [Username]=@Username"
                    .Parameters.AddWithValue("@field1", txtUsername.Text)
                End With
                SqlCommand.Connection = conn
                dbRdr = SqlCommand.ExecuteReader
                If dbRdr.HasRows = True Then
                    dbRdr.Read()
                    If dbRdr.Item(0) = 0 Then
                        With SqlCommand
                            .CommandText = SqlQuery
                            .Connection = conn
                            .ExecuteNonQuery()
                        End With
                        dbRdr.Close()
                        MsgBox("New user has been added!")
                    Else
                        MsgBox("Username is not currently available, please choose new username.")
                    End If
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Classcan someone help me with this? Thanks in advance!
 
	 
 
		 
 
		 
 
		