Puedes crear una variable boolean
en el TryCatch
.Te adjunto el siguiente codigo que usa como ejemplo una conexion a MySQL:
Dim iReturn as boolean
Using SQLConnection As New MySqlConnection(connectionString)
Using sqlCommand As New MySqlCommand()
With sqlCommand
.CommandText = "INSERT INTO members_car (`car_id`, `member_id`, `model`, `color`, `chassis_id`, `plate_number`, `code`) values (@xid,@m_id,@imodel,@icolor,@ch_id,@pt_num,@icode)"
.Connection = SQLConnection
.CommandType = CommandType.Text // You missed this line
.Parameters.AddWithValue("@xid", "valor1")
.Parameters.AddWithValue("@m_id", "valor2")
.Parameters.AddWithValue("@imodel", "valor3")
.Parameters.AddWithValue("@icolor", "valor4")
.Parameters.AddWithValue("@ch_id", "valor5")
.Parameters.AddWithValue("@pt_num", "valor6")
.Parameters.AddWithValue("@icode", "valor7")
End With
Try
SQLConnection.Open()
sqlCommand.ExecuteNonQuery()
iReturn = TRUE
Catch ex As MySqlException
MsgBox ex.Message.ToString
iReturn = False
Finally
SQLConnection.Close()
End Try
End Using
End Using
Return iReturn