CONSULTA SOBRE .NET(INGRESAR CLIENTE)
Publicado por mauricio (2 intervenciones) el 28/06/2007 20:59:08
Hola:
Les explico... estoy tratando de cambiarme desde visual basic 6.0 a visual.net. Y mi duda es la siguiente, hice un formulario de CLIENTES, donde tengo mis respectivos de botones de ingresar, modificar, buscar y salir, hasta aqui creo que todo bien PERO a la hora de meterle codigo YO LO HAGO COMO EN VISUAL BASIC 6.0 OSEA PROGRAMANDO EL EVENTO DE CADA BOTON, ES DECIR HAGO DOBLE CLICK EN EL BOTON INGRESAR Y EN EL EVENTO CLICK METO EL CODIGO PARA INGRESAR(QUE POR CIERTO FUNCIONA).
LA DUDA QUE TENGO ES SI ES CORRECTO LO QUE ESTOY HACIENDO(POR QUE HASTA AHORA ES COMO PROGRAMAR EN VISUAL 6.0) O DEBERÍA CREAR UN CLASE CLIENTE CON LOS METODOS DE INGRESAR, MODIFICAR...ETC. Y BLA BLA BLA. Y SI ES ASI COMO SERÍA LA ESTRUCTURA DE LA CLASE?????
ESTOY UN POCO CONFUNDIDO CON ESTO DE LOS METODOS, HERENCIA, PROPIEDADES.....
MI CODIGO PARA INGRESAR ES EL SIGUIENTE:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' crear conexión
Dim con As New SqlConnection
con.ConnectionString = "server=IPVG-MDZJN0AZ1G;uid=sa;pwd=;database=sigaltda;"
' crear sentencia SQL
Dim sSQL As String
sSQL = "Insert Into clientes (rut_cliente,nombres, apellidos,direccion,comuna,ciudad,telefono,mail,giro,tipo,contacto) values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox11.Text & "','" & ComboBox1.Text & "','" & TextBox9.Text & "')"
Dim oComando As New SqlCommand(sSQL, con)
con.Open() ' abrir conexión
oComando.ExecuteNonQuery() ' ejecutar comando
con.Close() ' cerrar conexión
ESTO DEBERÍA SER UN METODO????YCOMO LO HAGO??????
OJALA ME PUEDAN AYUDAR
SALUDOS
Les explico... estoy tratando de cambiarme desde visual basic 6.0 a visual.net. Y mi duda es la siguiente, hice un formulario de CLIENTES, donde tengo mis respectivos de botones de ingresar, modificar, buscar y salir, hasta aqui creo que todo bien PERO a la hora de meterle codigo YO LO HAGO COMO EN VISUAL BASIC 6.0 OSEA PROGRAMANDO EL EVENTO DE CADA BOTON, ES DECIR HAGO DOBLE CLICK EN EL BOTON INGRESAR Y EN EL EVENTO CLICK METO EL CODIGO PARA INGRESAR(QUE POR CIERTO FUNCIONA).
LA DUDA QUE TENGO ES SI ES CORRECTO LO QUE ESTOY HACIENDO(POR QUE HASTA AHORA ES COMO PROGRAMAR EN VISUAL 6.0) O DEBERÍA CREAR UN CLASE CLIENTE CON LOS METODOS DE INGRESAR, MODIFICAR...ETC. Y BLA BLA BLA. Y SI ES ASI COMO SERÍA LA ESTRUCTURA DE LA CLASE?????
ESTOY UN POCO CONFUNDIDO CON ESTO DE LOS METODOS, HERENCIA, PROPIEDADES.....
MI CODIGO PARA INGRESAR ES EL SIGUIENTE:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' crear conexión
Dim con As New SqlConnection
con.ConnectionString = "server=IPVG-MDZJN0AZ1G;uid=sa;pwd=;database=sigaltda;"
' crear sentencia SQL
Dim sSQL As String
sSQL = "Insert Into clientes (rut_cliente,nombres, apellidos,direccion,comuna,ciudad,telefono,mail,giro,tipo,contacto) values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox11.Text & "','" & ComboBox1.Text & "','" & TextBox9.Text & "')"
Dim oComando As New SqlCommand(sSQL, con)
con.Open() ' abrir conexión
oComando.ExecuteNonQuery() ' ejecutar comando
con.Close() ' cerrar conexión
ESTO DEBERÍA SER UN METODO????YCOMO LO HAGO??????
OJALA ME PUEDAN AYUDAR
SALUDOS
Valora esta pregunta


0