miércoles, 4 de diciembre de 2013

DATAGRID
El DataGrid es un control de Visual Basic en la que puedes insertar los campos de una tabla. 
El nombre por defecto es Datagrid1 y allí te va un pedazo de có 'Activar DataGrid 
DataGrid1.Visible = True 

If (txtPNombre.Text <> "" And txtSNombre.Text <> "" And txtPApellido.Text <> "" And txtSApellido <> "") Then 
Adodc1.RecordSource = "SELECT IDENTIDAD,NOMBRE01,NOMBRE02,APELLIDO01,A... FROM DVT WHERE NOMBRE01='" & txtPNombre.Text & "' AND NOMBRE02= '" & txtSNombre.Text & "' AND APELLIDO01='" & txtPApellido & "' AND APELLIDO02= '" & txtSApellido.Text & "' " 
Else 
If (txtPNombre.Text <> "" And txtSNombre.Text <> "" And txtPApellido.Text <> "" And txtSApellido = "") Then
Adodc1.RecordSource = "SELECT IDENTIDAD,NOMBRE01,NOMBRE02,APELLIDO01,A... FROM DVT WHERE NOMBRE01='" & txtPNombre.Text & "' AND NOMBRE02= '" & txtSNombre.Text & "' AND APELLIDO01='" & txtPApellido & "' " 
Else 
If (txtPNombre.Text <> "" And txtSNombre.Text = "" And txtPApellido.Text <> "" And txtSApellido <> "") Then
Adodc1.RecordSource = "SELECT IDENTIDAD,NOMBRE01,NOMBRE02,APELLIDO01,A... FROM DVT WHERE NOMBRE01='" & txtPNombre.Text & "' AND APELLIDO01='" & txtPApellido & "' AND APELLIDO02= '" & txtSApellido.Text & "' " 
Else 
Adodc1.RecordSource = "SELECT IDENTIDAD,NOMBRE01,NOMBRE02,APELLIDO01,A... FROM DVT WHERE NOMBRE01='" & txtPNombre.Text & "' AND APELLIDO01='" & txtPApellido.Text & "' " 
End If 
End If 
End If 
Adodc1.Refresh 
With Adodc1.Recordset 
If Not .EOF Then 
DataGrid1.ClearFields 
Set DataGrid1.DataSource = Adodc1 
Else 
MsgBox "No se encuentra la información de esa persona", vbCritical, "Resultados" 
'Limpiar la pantalla 
txtPNombre.Text = "" 
txtSNombre.Text = "" 
txtPApellido.Text = "" 
txtSApellido.Text = "" 
DataGrid1.ClearFields 
DataGrid1.Visible = False 

txtPNombre.Enabled = True 
txtSNombre.Enabled = True 
txtPApellido.Enabled = True 
txtSApellido.Enabled = True 
cmdBuscar.Enabled = False 
txtPNombre.SetFocus 
cmdLimpiar.Enabled = False 
End If 
End With 
'Activar botón de limpiar 
cmdLimpiar.Enabled = True 
cmdBuscar.Enabled = False 
digo, talvez te sirva.