
31/03/2005, 12:03
|
 | | | Fecha de Ingreso: diciembre-2004
Mensajes: 365
Antigüedad: 20 años, 2 meses Puntos: 1 | |
Pues asi lo hice y nada
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)
Dim dr As sqldatareader
MyCommand.Connection.Open()
dr = mycommand.executereader
While dr.read
Dim UpdateCmd As String
If RadioButton1.Checked = true then
UpdateCmd ="update Formulario set Respuesta1 = "& (Ctype(dr("Respuesta1"),Integer) + 1) & " where formulario = 2"
Else If RadioButton2.Checked = true then
UpdateCmd ="update Formulario set Respuesta2 = "& (Ctype(dr("Respuesta2"),Integer) + 1) & " where formulario = 2"
Else If RadioButton3.Checked = true then
UpdateCmd ="update Formulario set Respuesta3 = "& (Ctype(dr("Respuesta3"),Integer) + 1) & " where formulario = 2"
Else If RadioButton4.Checked = true then
UpdateCmd ="update Formulario set Respuesta4 = "& (Ctype(dr("Respuesta4"),Integer) + 1) & " where formulario = 2"
Else If RadioButton5.Checked = true then
UpdateCmd ="update Formulario set Respuesta5 = "& (Ctype(dr("Respuesta5"),Integer) + 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
end while
dr.close
MyCommand.Connection.Close()
End Sub |