0% found this document useful (0 votes)
33 views4 pages

Conexioncqlyvb

This code defines a class that connects to a SQL database table called "clientes" and displays data from its rows. It opens a SQL connection, selects data from the clientes table, and fills a dataset. Buttons allow incrementing, decrementing, resetting, and going to the last row to display the selected row's data in textboxes. Another button inserts a new row into the clientes table. The global.asax file defines application events like start, end, and error, and initializes the session variable "xp" to -1.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

Conexioncqlyvb

This code defines a class that connects to a SQL database table called "clientes" and displays data from its rows. It opens a SQL connection, selects data from the clientes table, and fills a dataset. Buttons allow incrementing, decrementing, resetting, and going to the last row to display the selected row's data in textboxes. Another button inserts a new row into the clientes table. The global.asax file defines application events like start, end, and error, and initializes the session variable "xp" to -1.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Imports System.

Data
Imports System.Data.SqlClient
Imports System.Data.Sql
Partial Class prueba
Inherits System.Web.UI.Page
Public CN As New SqlConnection
Public CMDclientes As New SqlCommand
Public DAclientes As New SqlDataAdapter
Public CMBclientes As New SqlCommandBuilder
Public DSbancomatico As New DataSet
Public P As Integer
Protected Sub Button1_Click(sender As Object,
e As EventArgs) Handles Button1.Click
Session("XP") = Session("XP") + 1
MOSTRARDATOS(Session("XP"))

End Sub

Protected Sub Page_Load(sender As Object, e


As EventArgs) Handles Me.Load
CN.ConnectionString = "DATA
SOURCE=(LOCAL);INITIAL
CATALOG=BANCOMATICO;INTEGRATED SECURITY=TRUE"
CN.Open()
CMDclientes.Connection = CN
CMDclientes.CommandText = "select * from
clientes"
DAclientes.SelectCommand = CMDclientes
DAclientes.Fill(DSbancomatico,
"clientes")
CMBclientes.DataAdapter = DAclientes

End Sub
Sub MOSTRARDATOS(X)
TextBox1.Text =
DSbancomatico.Tables("CLIENTES").Rows(X)(0)
TextBox2.Text =
DSbancomatico.Tables("CLIENTES").Rows(X)(1)
TextBox3.Text =
DSbancomatico.Tables("CLIENTES").Rows(X)(2)
TextBox4.Text =
DSbancomatico.Tables("CLIENTES").Rows(X)(3)

End Sub
Protected Sub Button2_Click(sender As Object,
e As EventArgs) Handles Button2.Click
Session("XP") = Session("XP") - 1
MOSTRARDATOS(Session("XP"))
End Sub

Protected Sub Button3_Click(sender As Object,


e As EventArgs) Handles Button3.Click
Session("XP") = 0
MOSTRARDATOS(Session("XP"))
End Sub

Protected Sub Button4_Click(sender As Object,


e As EventArgs) Handles Button4.Click
Session("XP") =
DSbancomatico.Tables("CLIENTES").Rows.Count - 1
MOSTRARDATOS(Session("XP"))
End Sub

Protected Sub Button6_Click(sender As Object,


e As EventArgs) Handles Button6.Click
Dim S, X As String
X = TextBox1.Text
S = "INSERT INTO
CLIENTES(CODIGOCLIENTE,APE_PATERNO,APE_MATERNO,NO
MBRES) "
S = S + " VALUES( '" & X & "' , '" &
TextBox2.Text & "' , '" & TextBox3.Text & "' ,
'" & TextBox4.Text & "' ) "
CMDclientes.CommandText = S
CMDclientes.ExecuteNonQuery()
MsgBox("SE AGREGO EL NUEVO CLIENTE")
End Sub

Protected Sub Button5_Click(sender As Object,


e As EventArgs) Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Focus()
End Sub
End Class
Global.asax

<%@ Application Language="VB" %>


<%@ Import Namespace="System.Web.Optimization" %>

<script runat="server">

Sub Application_Start(ByVal sender As Object,


ByVal e As EventArgs)
' Code that runs on application startup

BundleConfig.RegisterBundles(BundleTable.Bundles)
AuthConfig.RegisterOpenAuth()
End Sub

Sub Application_End(ByVal sender As Object,


ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub

Sub Application_Error(ByVal sender As Object,


ByVal e As EventArgs)
' Code that runs when an unhandled error
occurs
End Sub
Sub Session_start()
Session("xp") = -1
End Sub
</script>

You might also like