pagina aspx:
codice:
Company
<asp:TextBox ID="txtCompany" runat="server" Width="226px"></asp:TextBox>
Contact
<asp:TextBox ID="txtContact" runat="server" Width="224px"></asp:TextBox>
Telephone
<asp:TextBox ID="txtTel" runat="server" style="margin-bottom: 0px"
Width="225px"></asp:TextBox>
E-mail
<asp:TextBox ID="txtMail" runat="server" Width="223px"></asp:TextBox>
Address
<asp:TextBox ID="txtAddress" runat="server" Width="222px"></asp:TextBox>
Cap
<asp:TextBox ID="txtCap" runat="server" Width="96px"></asp:TextBox>
City
<asp:TextBox ID="txtCity" runat="server" Width="227px"></asp:TextBox>
Country
<asp:TextBox ID="txtCountry" runat="server" Width="221px"></asp:TextBox>
<asp:Button ID="btnUpdate" runat="server" Text="Update" />
codice vb
codice:
'Riempimento dei campi
Private Sub fillForm()
connectDb()
myCommand = New SqlCommand("SELECT company, contact, tel, email, address, cap, city, country FROM clients WHERE id_client = '" & Session.Item("User") & "'", myConnection)
dr = myCommand.ExecuteReader()
If dr.Read() Then
txtCompany.Text = Trim(dr(0).ToString)
txtContact.Text = Trim(dr(1).ToString)
txtTel.Text = Trim(dr(2).ToString)
txtMail.Text = Trim(dr(3).ToString)
txtAddress.Text = Trim(dr(4).ToString)
txtCap.Text = Trim(dr(5).ToString)
txtCity.Text = Trim(dr(6).ToString)
txtCountry.Text = Trim(dr(7).ToString)
End If
myConnection.Close()
End Sub
'Lettura campi per update
Function updateData()
connectDb()
myCommand = New SqlCommand("UPDATE clients SET company = @company, contact = @contact, tel = @tel, email = @email, " + _
"address = @address, cap = @cap, city = @city, country = @country " + _
"WHERE id_client = '" & Session.Item("User") & "'", myConnection)
myCommand.Parameters.AddWithValue("@company", txtCompany.Text)
myCommand.Parameters.AddWithValue("@contact", txtContact.Text)
myCommand.Parameters.AddWithValue("@tel", txtTel.Text)
myCommand.Parameters.AddWithValue("@email", txtMail.Text)
myCommand.Parameters.AddWithValue("@address", txtAddress.Text)
myCommand.Parameters.AddWithValue("@cap", txtCap.Text)
myCommand.Parameters.AddWithValue("@city", txtCity.Text)
myCommand.Parameters.AddWithValue("@country", txtCountry.Text)
myCommand.ExecuteNonQuery()
myConnection.Close()
Response.Redirect("client_home.aspx")
End Function