Seria algo por el estilo
Código VB:
Ver originalDim Comando As New OleDbCommand
With Comando
Cone.Open()
.CommandText = "Insert into Alumnos values (@Credencial, @Nombre, @Direccion, @Telefono)"
.Connection = Cone
.Parameters.Add("@Credencial", OleDbType.Char, 10).Value = Me.TextBox3.Text
.Parameters.Add("@Nombre", OleDbType.VarChar, 50).Value = Me.TextBox1.Text
.Parameters.Add("@Direccion", OleDbType.VarChar, 50).Value = Me.TextBox2.Text
.Parameters.Add("@Telefono", OleDbType.VarChar, 50).Value = Me.TextBox4.Text
End With
Dim Bien As Integer = Comando.ExecuteNonQuery
If Bien = 0 Then
Throw New Exception("Falló la operacion de inserción")
End If
Comando.Dispose()
Cone.Close()
Cone.Dispose()
MessageBox.Show("Datos Ingresados con éxito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Operacion cancelada por el usuario", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub