• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Visual Studio.Net - Sql Server
 

Visual Studio.Net - Sql Server

on

  • 8,809 views

Tres formas para manipular registros desde Visual Basic.Net a una Base de Datos en Sql Server.

Tres formas para manipular registros desde Visual Basic.Net a una Base de Datos en Sql Server.

Statistics

Views

Total Views
8,809
Views on SlideShare
8,616
Embed Views
193

Actions

Likes
32
Downloads
0
Comments
3

5 Embeds 193

http://sistemasddm.blogspot.com 158
http://www.sistemasddm.blogspot.com 31
http://sistemasddm.blogspot.mx 2
http://www.sistemasddm.blogspot.com.es 1
http://sistemasddm.blogspot.com.ar 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

13 of 3 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Visual Studio.Net - Sql Server Visual Studio.Net - Sql Server Document Transcript

    • http://sistemasddm.blogspot.comtkd.ddm@gmail.comPRIMERA FORMA EN ADO.NETVISUAL.NETImports System.Data.SqlClientPublic Class Form1Dim CN As New SqlConnection("data source= . ; database = Northwind ; integrated security = true")Dim DS As New DataSetDim DA As SqlDataAdapterDim BUSCAR As IntegerPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.LoadDA = New SqlDataAdapter("select * from Employees", CN)DS = New DataSetDA.Fill(DS, "Employees")Me.DataGridView1.DataSource = DS.Tables("Employees")End SubPrivate Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnnuevo.ClickMe.txtbuscar.Enabled = TrueMe.txtbuscar.Text = ""End Sub
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.comPrivate Sub btnbuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnbuscar.ClickDim objdataview As New DataViewDim buscar As IntegerMe.DataGridView1.DataSource = Nothingbuscar = Me.txtbuscar.Textobjdataview.Table = DS.Tables("Employees")objdataview.RowFilter = "employeeid= " & buscar & ""If objdataview.Count > 0 ThenMe.DataGridView1.DataSource = objdataviewMe.DataGridView1.Refresh()ElseMsgBox("registro no encontrado", MsgBoxStyle.Information, "advertencia")End IfMe.txtbuscar.Enabled = FalseEnd SubEnd Class
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.comSEGUNDA FORMA EN ADO.NETVISUAL BASIC.NETUSE MASTERCREATE TABLE EMPLEADOS(CODIGO NVARCHAR(5),NOMBRE NVARCHAR(25),APELLIDOS NVARCHAR (25),DIRECCION NVARCHAR (25),TELEFONO NVARCHAR (25))INSERT INTO EMPLEADOSVALUES (E0001, RICHARD, RAMOS BARRIOS , LA VISTORIA, 997798005)INSERT INTO EMPLEADOSVALUES (E0002, JUAN , CARLOS ROJAS , MOLINA, 997798008)INSERT INTO EMPLEADOSVALUES (E0003, CARLOS, LOLO CARLOS , COMAS, 997798007)INSERT INTO EMPLEADOSVALUES (E0004, NILDA, DURAND MORILLO , LIMA, 997798009)Imports System.Data.SqlClientPublic Class Form1Dim CN As New SqlConnection("data source= . ;user id = 123 ; database = master ; integrated security= true")
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.comDim DS As New DataSetDim DA As SqlDataAdapterDim dW As New DataViewPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.LoadDA = New SqlDataAdapter("SELECT * FROM EMPLEADOS", CN)DS = New DataSetDA.Fill(DS, "EMPLEADOS")Me.DataGridView1.DataSource = DS.Tables("EMPLEADOS")End SubPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnnuevo.ClickDim ctr As ControlFor Each ctr In Me.ControlsIf TypeOf ctr Is TextBox Then ctr.Text = ""Me.DataGridView1.DataSource = NothingNextEnd SubPrivate Sub btnbuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnbuscar.ClickMe.DataGridView1.DataSource = NothingdW.Table = DS.Tables("empleados")dW.RowFilter = "codigo = " & txtcodigo.Text & ""If dW.Count > 0 ThenMe.DataGridView1.DataSource = dWMe.DataGridView1.Refresh()Me.txtcodigo.Text = Me.DataGridView1.Item(0, 0).ValueMe.txtnombre.Text = Me.DataGridView1.Item(1, 0).ValueMe.txtapellidos.Text = Me.DataGridView1.Item(2, 0).ValueMe.txtdireccion.Text = Me.DataGridView1.Item(3, 0).ValueMe.txttelefono.Text = Me.DataGridView1.Item(4, 0).ValueElseMsgBox("REGISTRO NO ENCONTRADO")End IfEnd SubEnd Class
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.comTERCERA FORMA ADO.NETVISUAL BASIC.NETUSE MASTERCREATE TABLE EMPLEADOS(CODIGO NVARCHAR(5),NOMBRE NVARCHAR(25),APELLIDOS NVARCHAR (25),DIRECCION NVARCHAR (25),TELEFONO NVARCHAR (25))INSERT INTO EMPLEADOS VALUES (E0001, RICHARD , RAMOS BARRIOS , LA VISTORIA,997798005)INSERT INTO EMPLEADOS VALUES (E0002, JUAN , CARLOS ROJAS , MOLINA, 997798008)INSERT INTO EMPLEADOS VALUES (E0003, CARLOS , LOLO CARLOS , COMAS, 997798007)INSERT INTO EMPLEADOS VALUES (E0004, NILDA , DURAND MORILLO , LIMA, 997798009)select * from empleados
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.com
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.comImports System.Data.SqlClientPublic Class form1Dim CN As New SqlConnection("data source= . ; database = MASTER; integrated security = true")Dim cmd As SqlCommandDim dr As SqlDataReaderPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnsalir.ClickEndEnd SubPrivate Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnnuevo.ClickDim ctrl As ControlFor Each ctrl In Me.ControlsIf TypeOf ctrl Is TextBox Then ctrl.Text = ""NextMe.btnnuevo.Text = "buscar"End SubPrivate Sub btnbuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesbtnbuscar.ClickTryIf btnbuscar.Text = "buscar" ThenMe.btnbuscar.Text = "buscar ahora"Me.txtcodigo.Enabled = TrueMe.txtcodigo.Focus()Elsecmd = New SqlCommand("select * from empleados where codigo = " & Me.txtcodigo.Text & "", CN)CN.Open()dr = cmd.ExecuteReaderIf dr.Read ThenMe.txtnombre.Text = dr("nombre")Me.txtapellidos.Text = dr("apellidos")Me.txtdireccion.Text = dr("direccion")Me.txttelefono.Text = dr("telefono")ElseMessageBox.Show("el codigo no existe", "error", MessageBoxButtons.OK,MessageBoxIcon.Information)End IfCN.Close()End IfCatch ex As ExceptionMessageBox.Show(ex.Message)End TryEnd SubEnd Class
    • http://sistemasddm.blogspot.comtkd.ddm@gmail.com