Я получил сообщение об ошибке There is an open data reader associated with this command which needs to be closed first
, используя следующий код:
myCommand = New SqlCommand("SELECT BookCode FROM tblBook",myConnection)
myReader = myCommand.ExceuteReader
While myReader.Read
If myReader(0).ToString <> txtBookCode.Text Then
myCommand = New SqlCommand("INSERT INTO tblBook VALUES(@BookCode, @BookTitle)",myConnection)
myCommand.Parameters.AddWithValue("@BookCode", txtBookCode.Text)
myCommand.Parameters.AddWithValue("@BookTitle", txtBookTitle.Text)
myCommand.ExecuteNonQuery()
Else
MsgBox("There is already a book name '"& txtTitle.Text "'. Please try another code.",vbOkOnly,"BookCode Exists")
End If
End While
Пожалуйста, помогите.