Metodo agregar visual studio 2010

Solo disponible en BuenasTareas
  • Páginas : 2 (291 palabras )
  • Descarga(s) : 4
  • Publicado : 6 de junio de 2010
Leer documento completo
Vista previa del texto
Imports System.Data.SqlClient
Public Class Form1
Inherits Windows.Forms.Form
Private conexion As New SqlConnection
Private ds As DataSet
Private dt As New SqlDataAdapterPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conexion = New SqlConnection
conexion.ConnectionString = "DataSource=JUANDEDIOS;Initial Catalog=agenda;Integrated Security=True"
dt = New SqlDataAdapter
Dim insercion As New SqlCommand("INSERT INTO AGENDA" &"(IDPersona,Nombre,ape_pat,ape_mat,direccion,colonia,ciudad,telefono,celular,e_mail,apodo)Values(@IDPersona,@Nombre,@ape_pat,@ape_mat,@direccion,@colonia,@ciudad,@telefono,@celular,@e_mail,@apodo)", conexion)
dt.InsertCommand = inserciondt.InsertCommand.Parameters.Add(New SqlParameter("@IDPersona", SqlDbType.Int))
dt.InsertCommand.Parameters.Add(New SqlParameter("@Nombre", SqlDbType.Char))dt.InsertCommand.Parameters.Add(New SqlParameter("@ape_mat", SqlDbType.Char))
dt.InsertCommand.Parameters.Add(New SqlParameter("@ape_pat", SqlDbType.Char))
dt.InsertCommand.Parameters.Add(NewSqlParameter("@direccion", SqlDbType.Char))
dt.InsertCommand.Parameters.Add(New SqlParameter("@colonia", SqlDbType.Char))
dt.InsertCommand.Parameters.Add(New SqlParameter("@ciudad",SqlDbType.Char))
dt.InsertCommand.Parameters.Add(New SqlParameter("@telefono", SqlDbType.Char))
dt.InsertCommand.Parameters.Add(New SqlParameter("@celular", SqlDbType.Char))dt.InsertCommand.Parameters.Add(New SqlParameter("@e_mail", SqlDbType.Char))
dt.InsertCommand.Parameters.Add(New SqlParameter("@apodo", SqlDbType.Char))

Dim consulta As NewSqlCommand("SELECT * FROM agenda", conexion)
dt.SelectCommand = consulta
ds = New DataSet
Me.cargardatos()
End Sub
Private Sub cargardatos()
'vaciar el database...
tracking img