ASP.NET - problema codigo

 
Vista:

problema codigo

Publicado por lala.mtts (15 intervenciones) el 24/03/2008 14:59:10
hola a todos: miren tengo el siguiente código, donde hay 7 input's donde al salir del último input quiero que me guarde, pero no se como hacerlo porque no lo hace. aqui les envio el código

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim login As String
login = Session("nombre")

If login = "" Then
Response.Status = "401 Prohibido"
Response.End()
Else
Label11.Visible = True
Label11.Text = login
Dim id_paciente As String
id_paciente = Request.QueryString("id_paciente")

Hidden2.Value = id_paciente


Dim conecion3 As SqlConnection
Dim consulta3 As SqlCommand

conecion3 = New SqlConnection("Data Source=URGPEDIATRICA;Initial Catalog=hospital;Persist Security Info=True;User ID=sa;Password=sa")
consulta3 = New SqlCommand("select ae,ap,pp,pt,mn,mnn,hv from form_obs_emb_previos WHERE ID_PACIENTE=@id", conecion3)
consulta3.Parameters.Add("@id", Data.SqlDbType.Int)
consulta3.Parameters("@id").Value = id_paciente

conecion3.Open()
Dim mostrar3 As SqlDataReader = consulta3.ExecuteReader((CommandBehavior.CloseConnection))
While mostrar3.Read()
txt_1.Value = CStr(mostrar3("ae"))
txt_2.Value = CStr(mostrar3("ap"))
txt_3.Value = CStr(mostrar3("pp"))
txt_4.Value = CStr(mostrar3("pt"))
txt_5.Value = CStr(mostrar3("mn"))
txt_6.Value = CStr(mostrar3("mnn"))
txt_7.Value = CStr(mostrar3("hv"))
End While
mostrar3.Close()
conecion3.Close()

If txt_1.Value = "" Then
valida = True
End If

If txt_2.Value = "" Then
valida = True
End If
If txt_3.Value = "" Then
valida = True
End If
If txt_4.Value = "" Then
valida = True
End If
If txt_5.Value = "" Then
valida = True
End If
If txt_6.Value = "" Then
valida = True
End If
If txt_7.Value = "" Then
valida = True
End If


If valida = False Then
btn_ingresar.Visible = False
btn_modificar.Visible = True
Else
btn_ingresar.Visible = True
btn_modificar.Visible = False

End If

txt_7.Attributes.Add("onBlur", "document.location='Embarazos_Previos.aspx?BANDERA=1'")

End If

If Not IsNothing(Request.QueryString("BANDERA")) Then
If valida = False Then
Table9.Visible = False
TABLE5.Visible = True
'Label28.Visible = False
Dim objConn As New OleDbConnection("Provider=SQLNCLI;Server=Urgpediatrica;Database=hospital;Uid=sa;Pwd=sa;")
Dim sSQL, Resul As String
sSQL = "insert into form_obs_emb_previos (ae, ap,pp,pt,mn,mnn,hv,id_paciente) values ('" & txt_1.Value & "','" & txt_2.Value & "','" & txt_3.Value & "','" & txt_4.Value & "','" & txt_5.Value & "','" & txt_6.Value & "','" & txt_7.Value & "','" & Hidden2.Value & "')"
Dim objCmd As New OleDbCommand(sSQL, objConn)
objConn.Open()
Resul = objCmd.ExecuteNonQuery
If Resul Then
Label8.Visible = True
Label8.Text = "(*) Se Ha Agregado Correctamente el Registro"
End If
objConn.Close()
paso = 2
Hidden1.Value = paso
Else
Table9.Visible = True
TABLE5.Visible = False
'Label28.Visible = True

Dim conecion1 As SqlConnection
Dim consulta1 As SqlCommand

conecion1 = New SqlConnection("Data Source=URGPEDIATRICA;Initial Catalog=hospital;Persist Security Info=True;User ID=sa;Password=sa")
consulta1 = New SqlCommand("UPDATE form_obs_emb_previos SET ae = '" + txt_1.Value + "', ap='" + txt_2.Value + "', pp='" + txt_3.Value + "', pt='" + txt_4.Value + "', mn='" + txt_5.Value + "', mnn='" + txt_6.Value + "', hv='" + txt_7.Value + "' WHERE id_paciente = '" + Hidden2.Value + "'", conecion1)
conecion1.Open()

consulta1.ExecuteNonQuery()

Label8.Visible = True
Label8.Text = "(*) Se Han Modificado los Registros"
conecion1.Close()
paso = 2
Hidden1.Value = paso
End If
End If
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder