Ver Mensaje Individual
  #4 (permalink)  
Antiguo 18/10/2010, 10:26
Avatar de gedarufi
gedarufi
 
Fecha de Ingreso: diciembre-2008
Ubicación: Colombia
Mensajes: 540
Antigüedad: 15 años, 4 meses
Puntos: 22
Respuesta: Datos de TextBox Visual Basic 2010 a Access

Seria algo por el estilo

Código VB:
Ver original
  1. Dim Comando As New OleDbCommand
  2. With Comando
  3. Cone.Open()
  4. .CommandText = "Insert into Alumnos values (@Credencial, @Nombre, @Direccion, @Telefono)"
  5. .Connection = Cone
  6. .Parameters.Add("@Credencial", OleDbType.Char, 10).Value = Me.TextBox3.Text
  7. .Parameters.Add("@Nombre", OleDbType.VarChar, 50).Value = Me.TextBox1.Text
  8. .Parameters.Add("@Direccion", OleDbType.VarChar, 50).Value = Me.TextBox2.Text
  9. .Parameters.Add("@Telefono", OleDbType.VarChar, 50).Value = Me.TextBox4.Text
  10. End With
  11. Dim Bien As Integer = Comando.ExecuteNonQuery
  12. If Bien = 0 Then
  13. Throw New Exception("Falló la operacion de inserción")
  14. End If
  15. Comando.Dispose()
  16. Cone.Close()
  17. Cone.Dispose()
  18. MessageBox.Show("Datos Ingresados con éxito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information)
  19. Catch ex As Exception
  20. MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error)
  21. End Try
  22. Else
  23. MessageBox.Show("Operacion cancelada por el usuario", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  24. End If
  25. End Sub