elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / como asignarle el resultado de una consulta de mysql a un textbox desde vb.net? en: 18 Marzo 2011, 21:09 pm
tengo el siguiente codigo:
  
Código
  1. Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbus.Click
  2.        conexion = New OdbcConnection("dsn=conexión_vb; uid= root; pwd= 123456;")
  3.      sql = " select nombre, apellido from docentes where identificacion= " & txtid.Text & ";"
  4.        comando = New OdbcCommand(sql, conexion)
  5.         Try
  6.          conexion.Open()
  7.  
  8.         leer = comando.ExecuteReader()
  9.         txtnombre = leer(0)
  10.        Txtap = leer(1)
  11.         Catch ex As Exception
  12.        MsgBox(ex.Message)
  13.          End Try
pero me sale un error que dice que la columna o fila no tiene datos pero esta llena en mysql.
por favor espero su ayuda es urgente.... :silbar:
2  Programación / .NET (C#, VB.NET, ASP) / Re: necesito de su ayuda en insertar datos en sql 2005 con visual basic.net en: 18 Marzo 2011, 21:01 pm
ps creo que este codigo te puede servir:
Código
  1. Public Class frm
  2.    Public conexion As OdbcConnection
  3.    Public comando As OdbcCommand
  4.    Public sql As String
  5. Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
  6.        conexion = New OdbcConnection("dsn=conexión_vb; uid= root; pwd= 123456;")
  7.        conexion.Open()
  8.  
  9.        Try
  10.  
  11.            sql = " INSERT INTO docentes VALUES( " & txtid.Text & ",'" & txtnombre.Text & "','" & txtap.Text & "'," & txttel.Text & ");"
  12.            comando = New OdbcCommand(sql, conexion)
  13.            comando.ExecuteNonQuery()
  14.            MsgBox("Los datos han sido guardados correctamente")
  15.        Catch ex As Exception
  16.            MsgBox(ex.Message)
  17.        End Try
  18.        txtid.Text = " "
  19.        txtnombre.Text = " "
  20.        txtap.Text = " "
  21.        txttel.Text = " "
  22.        txtid.Focus()
  23.    End Sub
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines