02/02/2011, 10:32
|
| | Fecha de Ingreso: enero-2011
Mensajes: 15
Antigüedad: 13 años, 9 meses Puntos: 0 | |
Respuesta: no se inserta Para Poblar el Datagrid
Sub Poblar_Datagrid()
Try
Dim conn As New MySQLConnection(conn)
Dim sql As String = "select * from clientes"
Dim DsActividad As New DataSet
Dim daactividad As New MySQLDataAdapter(sql, conn)
conn.Open()
daactividad.Fill(DsActividad, "clientes")
With Me.DataGrid1
.DataSource = DsActividad.Tables("clientes").DefaultView
End With
conn.Close()
Catch err As MySQLException
MessageBox.Show(err.Message)
Catch err As Exception
MessageBox.Show(err.Message)
End Try
End Sub
Para Insertar Datos
Sub incluir_cliente(ByVal camp1, ByVal camp2, ByVal camp3, ByVal camp4)
Timer1.Enabled = False
Dim conn As New MySQLConnection(conn)
Dim cmd As MySQLCommand
Dim sqlBuilder As New System.Text.StringBuilder
Try
With sqlBuilder
.Append("INSERT INTO clientes")
.Append("(campo1,campo2,campo3,campo4)")
.Append("VALUES ('")
.Append(camp1 & "','")
.Append(camp2 & "','")
.Append(camp3 & "','")
.Append(camp4 & "')")
End With
conn = New MySQLConnection((New MySQLConnectionString("localhost", "EPDT_DB", "alexander", "yolaima", 3306).AsString))
conn.Open()
cmd = New MySQLCommand(sqlBuilder.ToString, conn)
cmd.ExecuteNonQuery()
conn.Close()
cmd.Dispose()
conn.Dispose()
Catch err As MySQLException
Throw err
Catch err As Exception
Throw err
End Try
End Sub
despues que insertes un registro llamas Poblar_Datagrid() |