
31/03/2005, 09:02
|
 | | | Fecha de Ingreso: diciembre-2004
Mensajes: 365
Antigüedad: 20 años, 2 meses Puntos: 1 | |
Pues te cuento que hizo como me indicaste, o al menos eso creo yo.
Pero no funciona no setea el nuevo valor
en la tabla continua estando el valor cero
Entonces coloque un label antes del updatecdm
para ver si me trae el valor como me explicaste en post pasado
pero me da este error
Un valor de tipo 'Integer' no se puede convertir en '2'.
y resalta esta linea Label22 = (Ctype(dr("Respuesta1"),Integer)
El codigo del boton quedo asi
Sub Ok_Click(sender As Object, e As EventArgs)
Dim MyCommand As SqlCommand
Dim SelectCmd As String = "Select Respuesta1, Respuesta2, Respuesta3, Respuesta4, Respuesta5 from Formulario where FormularioID=2"
MyCommand = New SqlCommand(SelectCmd, PortalSettings.SqlConnectionString)
MyCommand.Connection.Open()
Dim dr As sqldatareader
dr = mycommand.executereader
Dim UpdateCmd As String
If RadioButton1.Checked = true then
Label22 = (Ctype(dr("Respuesta1"),Integer)
UpdateCmd ="update Formulario set Respuesta1 = "& (Ctype(dr("Respuesta1"),Integer) + 1) & " + 1 where formulario = 2"
Else If RadioButton2.Checked = true then
UpdateCmd ="update Formulario set Respuesta2 = "& (Ctype(dr("Respuesta2"),Integer) + 1) & " + 1 where formulario = 2"
Else If RadioButton3.Checked = true then
UpdateCmd ="update Formulario set Respuesta3 = "& (Ctype(dr("Respuesta3"),Integer) + 1) & " + 1 where formulario = 2"
Else If RadioButton4.Checked = true then
UpdateCmd ="update Formulario set Respuesta4 = "& (Ctype(dr("Respuesta4"),Integer) + 1) & " + 1 where formulario = 2"
Else If RadioButton5.Checked = true then
UpdateCmd ="update Formulario set Respuesta5 = "& (Ctype(dr("Respuesta5"),Integer) + 1) & " + 1 where formulario = 2"
end if
MyCommand = New SqlCommand(UpdateCmd, PortalSettings.SqlConnectionString)
Try
MyCommand.ExecuteNonQuery()
Catch Exp As SQLException
If Exp.Number = 2627
Message.InnerHtml = "ERROR: A record already exists with the same primary key"
Else
Message.InnerHtml = "ERROR: El registro no puede crearse, por favor revise los campos para ver si fueron rellenados correctamente" & Exp.Message
End If
Message.Style("color") = "red"
End Try
MyCommand.Connection.Close()
dr.close
MyCommand.Connection.Close()
End Sub |