Entradas

Mostrando entradas de diciembre 15, 2008

ACTUALIZAR UN REGISTRO CON UN PROCEDURE EN VB.NET

Dim cmd As New SqlCommand
cmd.CommandText = "sp_Actualizar"
cmd.Parameters.Add("@cod", SqlDbType.Char, 5).Value = TextBox1.Text cmd.Parameters.Add("@nom", SqlDbType.VarChar, 55).Value = TextBox2.Text cmd.Parameters.Add("@ape", SqlDbType.VarChar, 55).Value = TextBox3.Text cmd.Parameters.Add("@dir", SqlDbType.VarChar, 55).Value = TextBox4.Text cmd.CommandType = CommandType.StoredProcedure cmd.Connection = cn cmd.ExecuteNonQuery()
MsgBox("Cliente Actualizado !!!")

ELIMINAR UN REGISTRO CON UN PROCEDURE EN VB.NET

Dim cmd As New SqlCommand
cmd.CommandText = "sp_Eliminar"
cmd.Parameters.Add("@cod", SqlDbType.Char, 5).Value = TextBox1.Text cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = cn
cmd.ExecuteNonQuery()
MsgBox("Cliente Eliminado !!!")

GRABAR UN REGISTRO CON UN PROCEDURE EN VB.NET

Dim cmd As New SqlCommand
cmd.CommandText = "sp_Grabar"
cmd.Parameters.Add("@cod", SqlDbType.Char, 5).Value = TextBox1.Text cmd.Parameters.Add("@nom", SqlDbType.VarChar, 55).Value = TextBox2.Text cmd.Parameters.Add("@ape", SqlDbType.VarChar, 55).Value = TextBox3.Text cmd.Parameters.Add("@dir", SqlDbType.VarChar, 55).Value = TextBox4.Text cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = cn
cmd.ExecuteNonQuery()
MsgBox("Cliente Registrado !!!")

BUSQUEDA DE REGISTROS CON PRCEDURE EN VB.NET

Dim cmd As New SqlCommand
Dim buscar As String
buscar = InputBox("Ingrese el codigo a buscar:", "Busqueda de Clientes") cmd.CommandText = "sp_buscar"
cmd.Parameters.Add("@cod", SqlDbType.Char, 5).Value = buscar
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = cn
Dim rs As SqlDataReader
rs = cmd.ExecuteReader
While (rs.Read)
TextBox1.Text = rs.GetString(0)
TextBox2.Text = rs.GetString(1)
TextBox3.Text = rs.GetString(2)
TextBox4.Text = rs.GetString(3)
End While
rs.Close()//Prof. Jhonatan Abal M.