Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

ImportsSystem.Data.

SqlClient
PublicClassForm1

DimmyTransAsSqlTransaction
DimComandoAsSqlClient.SqlCommand
DimstrAccionAsString
DimconnAsSqlConnection=NewSqlConnection("Server=Dilmapc;
Database=PROYECTOS;UserID=sa;Password=sa;")
PrivateSubRecursos_FormClosed(ByValsenderAsObject,ByValeAs
System.Windows.Forms.FormClosedEventArgs)HandlesMe.FormClosed
conn.Close()
EndSub
PrivateSubRecursos_Load(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesMyBase.Load
Try
conn.Open()
TextBox1.Text="BasedeDatosPROYECTOSAbierta"
SqlRegistro()
SqlGridView()
CatchexAsException
MsgBox(ex.Message)
EndTry
EndSub
PrivateSubSqlRegistro()
Try
DimAdapter_PersonaAsNewSqlDataAdapter("Select*fromPERSONA",conn)
DimDataSet_PersonaAsNewDataSet
DimtableAsNewDataTable
DimregistroAsDataRow
Adapter_Persona.Fill(DataSet_Persona,"PERSONA")
table=DataSet_Persona.Tables("PERSONA")
ForEachregistroIntable.Rows
TextBox1.Text=registro("idpersona")
TextBox2.Text=registro("nombre")
TextBox3.Text=registro("apellido")
Next

CatchexAsException
MsgBox(ex.Message)
EndTry
EndSub
PrivateSubSqlGridView()
Try
DimadapterAsNewSqlDataAdapter("Select*fromPERSONA",conn)
'DimdsAsDataSet=NewDataSet
DimtableAsNewDataTable
table.Locale=System.Globalization.CultureInfo.InvariantCulture
adapter.Fill(table)
DataGridView1.AutoGenerateColumns=True
DataGridView1.DataSource=table
CatchexAsException
MsgBox(ex.Message)
EndTry
EndSub
EndClass

You might also like