INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Upcoming SlideShare
Loading in...5
×
 

INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER

on

  • 11,115 views

INSERCION DE REGISTROS DESDE VISUAL.NET A LA BD DE SQL SERVER

INSERCION DE REGISTROS DESDE VISUAL.NET A LA BD DE SQL SERVER

Statistics

Views

Total Views
11,115
Views on SlideShare
11,106
Embed Views
9

Actions

Likes
2
Downloads
812
Comments
2

2 Embeds 9

http://www.edmodo.com 8
http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER Document Transcript

  • INSERCION DE DATOS A UNA TABLA<br />VISUAL BASIC.NET<br />CREATE DATABASE EJERCICIO<br />USE EJERCICIO<br />CREATE TABLE PRUEBA<br />(CODIGO VARCHAR (5), <br />NOMBRE NVARCHAR (25), <br />APELLIDO NVARCHAR(25),<br />DIRECCION NVARCHAR(25), <br />TELEFONO FLOAT(53))<br />SELECT * FROM PRUEBA<br />CREAR UN MODULO<br />Imports System.Data.sqlclient<br />Module CONEXION<br /> Public cn As New SqlConnection(" server = (local); database = ejercicio; user id = sa; password=123" )<br />End Module<br />Imports System.Data.sqlclient<br />Public Class Form1<br /> Dim da As SqlDataAdapter<br /> Dim ds As DataSet<br /> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br /> End Sub<br /> Private Sub btngrabar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngrabar.Click<br /> Dim sql As String = " insert into PRUEBA values(@codigo, @nombre,@apellido, @direccion, @telefono)" <br /> Dim cmd As New SqlCommand(sql, cn)<br /> Try<br /> cmd.CommandType = CommandType.Text<br /> cmd.Parameters.Add(" @codigo" , SqlDbType.VarChar, 5).Value = Me.txtcodigo.Text<br /> cmd.Parameters.Add(" @nombre" , SqlDbType.NVarChar, 25).Value = Me.txtnombres.Text<br /> cmd.Parameters.Add(" @apellido" , SqlDbType.NVarChar, 25).Value = Me.txtapellidos.Text<br /> cmd.Parameters.Add(" @direccion" , SqlDbType.NVarChar, 20).Value = Me.txtdirecion.Text<br /> cmd.Parameters.Add(" @telefono" , SqlDbType.Float, 53).Value = Me.txttelefono.Text<br /> CN.Open()<br /> cmd.ExecuteNonQuery()<br /> MessageBox.Show(" REGISTRO INSERTADO CORRECTAMENTE" )<br /> Catch ex As Exception<br /> End Try<br /> End Sub<br /> Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnuevo.Click<br /> Me.txtcodigo.Text = " " <br /> Me.txtnombres.Text = " " <br /> Me.txtapellidos.Text = " " <br /> Me.txtdirecion.Text = " " <br /> Me.txttelefono.Text = " " <br /> End Sub<br />End Class<br />