Código vb:
Ver original
Public Class Form1 Dim cn As New SqlConnection("USER=LUISITO; DATABASE=CentroComercial;Integrated Security=yes")
Código vb:
Ver original
Function agregarPropietario(ByVal dni As Integer, ByVal ruc As Integer, ByVal nombre As String, ByVal ape As String, ByVal telefono As String) Dim a As String Try Dim cmd As New SqlCommand With cmd .Connection = cn .CommandType = CommandType.Text .CommandText = "Insert Propietarios(DNI,RUC,Nombres,Apellidos,Telefono)values(@dni,@ruc,@nom,@ape,@tel)" .Parameters.AddWithValue("@dni", dni) .Parameters.AddWithValue("@ruc", ruc) .Parameters.AddWithValue("@nom", nombre) .Parameters.AddWithValue("@ape", ape) .Parameters.AddWithValue("@tel", telefono) cn.Open() .ExecuteNonQuery() cn.Close() a = "Propietario Agregado" End With Catch ex As Exception a = ex.Message End Try Return a End Function
Código vb:
Ver original
Private Sub btnagregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnagregar.Click MsgBox(agregarPropietario(txtdni.Text, txtruc.Text, txtnom.Text, txtape.Text, txttel.Text)) End Sub
Gracias, Espero sus respuestas