Aggiornamento Dati.

sabato 07 gennaio 2006 - 17.45

freemark Profilo | Newbie

Ciao ragazzi mi servirebbe un piccolo aiuto con ASP.NET 2.
Perchè con il codice seguente non mi aggiorna i dati???
Praticamente ricarica la pagina e guindi i dati vecchi e non mi aggiorna mai i dati nuovi.

<script runat="server">

Dim strID As String

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

Me.strID = Request("ID")
Me.txtNome.Focus()

If Len(Trim(Me.strID)) <> 0 Then
Me.btnAzione.Text = "Aggiorna"
Me.CaricaDati()
If Len(Trim(Me.txtFoto.Text)) > 0 And Me.txtFoto.Text <> "Null" Then
Dim strErrore As String = Me.CaricaFoto()
If Len(strErrore) > 0 Then
Response.Write("Non è stato possibile caricare la foto per il seguente motivo: " & strErrore)
End If
End If
End If

End Sub

Private Sub CaricaDati()

Try
Dim dsDati As Data.DataSet = Nothing
Dim objSQL As New MSACCESS()

objSQL.SQL("SELECT * FROM TB_Studente WHERE ID_Studente=" & Me.strID & ";", dsDati)
Me.txtNome.Text = dsDati.Tables(0).Rows(0)("Nome").ToString()
Me.txtCognome.Text = dsDati.Tables(0).Rows(0)("Cognome").ToString()
Me.txtEtà.Text = dsDati.Tables(0).Rows(0)("Età").ToString()
Me.txtEmail.Text = dsDati.Tables(0).Rows(0)("Email").ToString()
Me.txtFoto.Text = dsDati.Tables(0).Rows(0)("Foto").ToString()

Catch ex As Exception
Response.Write("<p>" & ex.Message.ToString() & "</>")
End Try

End Sub

Private Function CaricaFoto() As String

Try
Me.imgFoto.ImageUrl = "Foto/" & Me.txtFoto.Text

Return Nothing

Catch Ex As Exception
Return Ex.Message
End Try

End Function

Private Sub btnAzione_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim strErrore As String

If Len(Trim(Me.strID)) = 0 Then

strErrore = Me.InserisciDati()
If Len(strErrore) > 0 Then
Response.Write("Errore di inserimento dati: " & strErrore)
Exit Sub
End If
Else
strErrore = Me.AggiornaDati()
If Len(strErrore) > 0 Then
Response.Write("Errore di aggiornamento dati: " & strErrore)
Exit Sub
End If

End If

If Me.fupFoto.HasFile Then
strErrore = Me.UploadFoto()
If Len(strErrore) > 0 Then
Response.Write("Non è stato possibile Uplodare la foto per il seguente motivo: " & strErrore)
End If
End If

If Len(Me.txtFoto.Text) > 0 And Me.txtFoto.Text <> "Null" Then
strErrore = Me.CaricaFoto()
If Len(strErrore) > 0 Then
Response.Write("Non è stato possibile caricare la foto per il seguente motivo: " & strErrore)
End If
End If

If Len(strErrore) = 0 Then
Response.Redirect("ElencoStudenti.aspx")
End If

End Sub

Private Function UploadFoto() As String

Try
CreateDirectory(Server.MapPath("Foto"))

Me.fupFoto.SaveAs(Server.MapPath("Foto/") & Me.txtFoto.Text)

Me.txtInfoFile.Text = "Grandezza File: " & Me.fupFoto.PostedFile.ContentLength & vbCrLf & _
"Tipo File: " & Me.fupFoto.PostedFile.ContentType


Return Nothing

Catch ex As Except
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5