
31/03/2005, 08:29
|
 | | | Fecha de Ingreso: diciembre-2004
Mensajes: 365
Antigüedad: 20 años, 2 meses Puntos: 1 | |
pues creo que te sigo
agrego en cada if bloque que falta, algo 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
If RadioButton1.Checked = true then
Dim UpdateCmd As String ="update Formulario set Respuesta1 = "& (Ctype(dr("Respuesta1"),Integer) + 1) & " + 1 where formulario = 2"
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()
Else If RadioButton2.Checked = true then
Dim UpdateCmd As String ="update Formulario set Respuesta2 = "& (Ctype(dr("Respuesta2"),Integer) + 1) & " + 1 where formulario = 2"
...
Else If RadioButton3.Checked = true then
Dim UpdateCmd As String ="update Formulario set Respuesta3 = "& (Ctype(dr("Respuesta3"),Integer) + 1) & " + 1 where formulario = 2"
...
Else If RadioButton4.Checked = true then
Dim UpdateCmd As String ="update Formulario set Respuesta4 = "& (Ctype(dr("Respuesta4"),Integer) + 1) & " + 1 where formulario = 2"
....
Else If RadioButton5.Checked = true then
Dim UpdateCmd As String ="update Formulario set Respuesta5 = "& (Ctype(dr("Respuesta5"),Integer) + 1) & " + 1 where formulario = 2"
...
end if
dr.close
MyCommand.Connection.Close()
End Sub
pero no le faltaria la linea
MyCommand.Parameters.Add(New SqlParameter("@Respuesta1", SqlDbType.Int, 4))
bueno que no seria @respuesta1 por que eso no estoy definiendo |