Dobry den, delam to nejak takto, respektive, jedna z variant:
Dim cmd As SqlClient.SqlCommand
cmd = New SqlClient.SqlCommand("UPDATE ZARIZENI SET PDA_ID = NULL WHERE (ZARIZENI_ID = @zarizeni_id)", SqlConnection1)
With cmd
.Parameters.Add("@zarizeni_id", SqlDbType.Int).Value = ListBox1.Tag
End With
Dim result As Integer
Try
result = cmd.ExecuteNonQuery()
Catch ex As SqlClient.SqlException
MessageBox.Show(ex.Message)
End Try
Jenze, nedari se mi rict serveru, ze NULL je opravdu NULL :-( Takze jsem zkousel neco takoveho:
Dim nic As New Object
nic = Nothing
Dim cmd As SqlClient.SqlCommand
cmd = New SqlClient.SqlCommand("UPDATE ZARIZENI SET PDA_ID = @pda_id WHERE (ZARIZENI_ID = @zarizeni_id)", SqlConnection1)
With cmd
.Parameters.Add("@zarizeni_id", SqlDbType.Int).Value = ListBox1.Tag
.Parameters.Add("@pda_id", SqlDbType.Int).Value = -1
End With
Dim result As Integer
Try
result = cmd.ExecuteNonQuery()
Catch ex As SqlClient.SqlException
MessageBox.Show(ex.Message)
End Try
Jenze to samozrejme take nefunguje :-)
|