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

qwertyuiopasdfghjklzxcvbnmqw

ertyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmqwertyui
DISEO DE LENGUAJE DE
opasdfghjklzxcvbnmqwertyuiopa
PROGRAMACION
sdfghjklzxcvbnmqwertyuiopasdf
CHAVEZ LOPE, Johan
ghjklzxcvbnmqwertyuiopasdfghj
klzxcvbnmqwertyuiopasdfghjklz
xcvbnmqwertyuiopasdfghjklzxcv
bnmqwertyuiopasdfghjklzxcvbn
mqwertyuiopasdfghjklzxcvbnmq
wertyuiopasdfghjklzxcvbnmqwe
rtyuiopasdfghjklzxcvbnmqwerty
uiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxcvbnmqwertyuiopas
dfghjklzxcvbnmqwertyuiopasdfg
RIVERA RIVERA, REMY

VISTA GRAFICA VISUAL BASIC

CODIGO EN VISUAL BASIC

Imports System.Data.SqlClient
Dim s, cons, sc As String
Dim i, x, b1, b2, a1, tc As Integer
Dim CN As New SqlConnection
Dim dv As New DataView
CN.ConnectionString = "Data Source=JO-HANN-PC;Initial
Catalog=tienda2;Integrated Security=True"
cons = ""
s = TextBox1.Text & " "
i = Len(s)
a1 = 0
For x = 1 To i
If Mid(s, x, 1) <> " " Then
If a1 = 0 Then
b1 = x
a1 = 1
End If
b2 = b2 + 1
End If
If Mid(s, x, 1) <> " " And Mid(s, x + 1, 1) = " " Then
sc = Mid(s, b1, b2).ToUpper
Select Case sc
Case "SELECCIONAR"
cons += "select "
tc = 1
Case "ELIMINAR"
cons += "delete "
tc = 2
Case "DE"

cons += "from "


Case "DONDE"
cons += "where "
Case "Y"
cons += "and "
Case "O"
cons += "or "
Case "TOP"
cons += "top "
Case "ORDENAR"
cons += "order by "
Case "ASCENDENTEMENTE"
cons += "asc "
Case "DESCENDENTEMENTE"
cons += "desc "
Case "LIMITE"
cons += "between "
Case Else
cons += sc & " "
End Select
a1 = 0
b2 = 0
End If
Next
Select Case tc
Case 1
Dim ds As New SqlDataAdapter(cons, CN)
Dim ww As New DataSet
Try
ds.Fill(ww)
dv.Table = ww.Tables(0)
DataGridView1.DataSource = dv
Catch ex As Exception
DataGridView1.DataSource = Nothing
MsgBox("Error en consulta Seleccionar", MsgBoxStyle.Critical,
"Error de consulta")
End Try
Case 2
CN.Open()
Try
Dim del As New SqlCommand(cons, CN)
del.ExecuteNonQuery()
DataGridView1.DataSource = Nothing
MsgBox("La fila se elimin exitosamente",
MsgBoxStyle.Information, "Consulta efectuada")
Catch ex As Exception
MsgBox("Consulta erronea", MsgBoxStyle.Exclamation, "No se puede
eliminar la Fila")
End Try
Case Else
MsgBox("No se reconoce la consulta", MsgBoxStyle.Critical, "Error en
consulta")
End Select

You might also like