You are on page 1of 1

Data Source=SANTI-PC\SQLEXPRESS;Initial Catalog=PLATANITOS;Integrated Security=True

"SERVER=localhost;UID=sa;PASSWORD=123;DATABASE=PLATANITOS"

Imports System
Imports System.Data.SqlClient

Public Class Form1


Dim conexion As New SqlConnection
Dim comando As New SqlCommand

Private Sub Form1_FormClosing(sender As Object, e As


System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
conexion.Close()

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

'MsgBox("ERROR EN LA CONEXION CON LA BASE DE DATOS",


MsgBoxStyle.Critical)

conexion.ConnectionString = ("Data Source=DESKTOP-


1GII5TK\MXCATVT;Initial Catalog=tienda;Integrated Security=True")
'conexion = New SqlConnection("data source=(local);initial
catalog=tienda;integrated security=true")
conexion.Open()
comando.Connection = conexion

Catch ex As Exception
MsgBox("ERROR EN LA CONEXION CON LA BASE DE DATOS",
MsgBoxStyle.Critical)

End Try
End Sub

Private Sub btnagregar_Click(sender As System.Object, e As System.EventArgs)


Handles btnagregar.Click
comando.CommandText = "insert into
tcliente(nom_cliente,ape_cliente,ciudad_cliente) values ('" & txtnom.Text & "','" &
txtape.Text & "','" & txtciu.Text & "')"
comando.ExecuteNonQuery()
txtape.Clear()
txtciu.Clear()
txtnom.Clear()
txtidclie.Clear()
txtnom.Focus()
End Sub
End Class

You might also like