You are on page 1of 1

Imports System.Data.

SqlClient
Imports System.Data.Sql
Public Class CONEXION
Public CN As SqlConnection
Public CMD As SqlCommand
Sub New()
Try
CN = New SqlConnection("Data Source=PC02;Initial Catalog=SISBD;Integrated
Security=True")
CN.Open()
MsgBox("CONECTADO")
Catch ex As Exception
MsgBox("NO ESTOY CONECTADO A LA BD" + ex.ToString)
End Try
End Sub
Function INSERTAPERSONA(ByVal CODIGO As String, ByVal NOMBRE As String, ByVal
APELLIDO As String, ByVal TELEFONO As String, ByVal EDAD As String)
Dim SALIDA As String = " LOS ELEMENTOS SE INSERTARON CORRECTAMENTE"
Try
CMD = New SqlCommand("INSERTAPERSONA", CN)
CMD.CommandType = CommandType.StoredProcedure
With CMD.Parameters
.AddWithValue("@CODIGO", CODIGO)
.AddWithValue("@NOMBRE", NOMBRE)
.AddWithValue("@APELLIDO", APELLIDO)
.AddWithValue("@TELEFONO", TELEFONO)
.AddWithValue("@EDAD", EDAD)
End With
Catch ex As Exception
Return SALIDA
End Try
End Function
End Class

Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
End Sub
End Class

You might also like