Получение этой ошибки со следующим запросом в SQL server 2014
У меня есть кнопки "Обновить"и " удалить". У них одни и те же ошибки...
Выражение небулевского типа, заданное в контексте, где ожидается условие, рядом с "ID".
Что я уже пробовал:
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click Try conn = New SqlConnection(strcon) conn.Open() Dim str As String = "Update PatientInfo set Surname=@Surname,Firstname=@Firstname,MI=@MI,Gender=@Gender,Birthday=@Birthday,Address=@Address,Contact=@Contact,Email=@Email Where Patient ID=@PID" cmd = New SqlCommand(str, conn) cmd.Parameters.AddWithValue("@Surname", txtSurname.Text) cmd.Parameters.AddWithValue("@Firstname", txtFirstname.Text) cmd.Parameters.AddWithValue("@MI", txtMI.Text) cmd.Parameters.AddWithValue("@Gender", CmbxGender.Text) cmd.Parameters.AddWithValue("@Birthday", dtpBday.Text) cmd.Parameters.AddWithValue("@Address", txtAdd.Text) cmd.Parameters.AddWithValue("@Contact", txtContact.Text) cmd.Parameters.AddWithValue("@Email", txtEmail.Text) cmd.Parameters.AddWithValue("@PID", txtPID.Text) cmd.ExecuteNonQuery() MessageBox.Show("Data has been updated!") loadData() cmd.Dispose() conn.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub '========================================================================== Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click Dim cmd As New SqlCommand Try conn.ConnectionString = strcon conn.Open() cmd.Connection = conn cmd.CommandText = "Delete from PatientInfo Where Patient ID=" + txtPID.Text cmd.ExecuteNonQuery() MessageBox.Show("Data has been deleted") loadData() conn.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
[no name]
Попробуйте [код пациента]=ПИД@