Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conexion As System.Data.OleDb.OleDbConnection
Dim comando As New System.Data.OleDb.OleDbCommand
Dim sql As String
conexion = New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.OLEDB.4.0; Data Source='C:ALTAS.xls'; Extended properties=Excel 8.0;")
conexion.Open()
comando.Connection = conexion
sql = "Insert into [hoja1$] (id,nombre) values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
comando.CommandText = sql
comando.ExecuteNonQuery()
conexion.Close()
MsgBox("Informacion Agregada")
End sub