Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/11/2011, 21:51
sachis77
 
Fecha de Ingreso: octubre-2011
Ubicación: COLOMBIA, Medellín
Mensajes: 42
Antigüedad: 12 años, 5 meses
Puntos: 0
programacion el visual basic

Hola , necesito que por favor me expliquen como concatenar en una tabla de subtipos tengo la clave primaria que es codsubt, la otra poimaria que es codt, y ala vez es foranea y el otro dato es nombre y yo lo tengo asi:

Private Sub cmdguardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdguardar.Click

Dim cs As Integer
Dim ct As Integer
Dim nom As String
Dim sql As String

If txtcsubtipo.Text.Length = 0 Then
MessageBox.Show("codigo no valido", "ERROR")
txtcsubtipo.Focus()
Exit Sub
End If

If xopcion = 1 Then
Dim xcantidad As Long = -1

miconexion = New MySqlConnection("server=localhost;user=root;passwo rd=111;database=prueba009")

miconexion.Open()

micomando = New MySqlCommand("select count(*)from subtprod =" & txtcsubtipo.Text & "", miconexion)
xcantidad = micomando.ExecuteScalar
miconexion.Close()
If xcantidad > 0 Then
MessageBox.Show("codigo digitado esta repetido", "ERROR")
txtcsubtipo.Focus()
Exit Sub
End If

End If

If txtctipo.Text.Length = 0 Then
MessageBox.Show("descripcion no valida", "ERROR")
txtctipo.Focus()
Exit Sub
ElseIf txtnombre.Text.Length = 0 Then
MessageBox.Show("nombre no valido", "ERROR")
txtnombre.Focus()
Exit Sub
End If


cs = Integer.Parse(txtcsubtipo.Text)
ct = Integer.Parse(txtctipo.Text)
nom = txtnombre.Text


If xopcion = 1 Then
sql = cs & ",'" & nom & "'," & ct
miconexion = New MySqlConnection("server=localhost;user=root;passwo rd=111;database=prueba009")
miconexion.Open()
micomando = New MySqlCommand("insert into subtprod values(" & sql & ")", miconexion)

micomando.ExecuteNonQuery()
miconexion.Close()
MessageBox.Show("Registro almacenado con exito", "observacion")

ElseIf xopcion = 2 Then
sql = "update subtprod set nomstp='" & nom & "',codt=" & ct & " where codsubtp =" & cs & ""
miconexion = New MySqlConnection("server=localhost;user=root;passwo rd=111;database=prueba009")
miconexion.Open()
micomando = New MySqlCommand(sql, miconexion)
micomando.ExecuteNonQuery()
miconexion.Close()
MessageBox.Show("registro Actualizado con exito", "Observacion")

End If

activar(False)

txtcsubtipo.Clear()
txtctipo.Clear()
txtnombre.Clear()

cmdagregar.Enabled = True
cmdguardar.Enabled = False
cmdborrar.Enabled = True
cmdbuscar.Enabled = True
cmdsalir.Enabled = True
cmdeditar.Enabled = True
cmdmayre.Enabled = True
cmdmenre.Enabled = True
cmdsig.Enabled = True
cmdant.Enabled = True
cmddeshace.Enabled = True





End Sub

muchas gracias por la ayuda que me puedan brindar