Hi all,
I’ve been trying to resolve this issue for like 10 hours but with no luck. I am trying to load data from a db to text boxes and allow the user to enter his/her modifications and click a button to update the db with the entered value in the textboxes. The problem is the entered data are not sent to the db but the data that are loaded when the page is loaded is what it goes to the db. I also tried vb codes and javascript to change the data of the textbox but that did not work.
here is my code:
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Imports System
Imports System.Data.OleDb
Imports System.Data.SqlClient
Partial Public Class BuyerProfile
Inherits System.Web.UI.Page
Private Sub BuyerProfile_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'MsgBox(userid)
If usergroup <> "b" Or isLogin = False Then
Server.Transfer("Default.aspx")
Else
conn.Open()
Dim cmd As New OracleCommand(sql, conn)
p_userid = New OracleParameter("p_userid", OracleDbType.Decimal, ParameterDirection.Input)
p_buyername = New OracleParameter("p_buyername", OracleDbType.Varchar2, ParameterDirection.Output)
p_opassword = New OracleParameter("p_opassword", OracleDbType.Varchar2, ParameterDirection.Output)
p_email = New OracleParameter("p_email", OracleDbType.Varchar2, ParameterDirection.Output)
p_shippingaddress = New OracleParameter("p_shippingaddress", OracleDbType.Varchar2, ParameterDirection.Output)
p_errorMsg = New OracleParameter("pErrorMsg", OracleDbType.Varchar2, ParameterDirection.Output)
cmd = New OracleCommand("getBuyerInfo", conn)
cmd.CommandType = CommandType.StoredProcedure
' declaring sizes of the db vars
p_userid.Size = 6
p_buyername.Size = 50
p_opassword.Size = 50
p_email.Size = 100
p_shippingaddress.Size = 100
p_errorMsg.Size = 100
p_userid.Value = userid
cmd.Parameters.Add(p_userid)
cmd.Parameters.Add(p_buyername)
cmd.Parameters.Add(p_opassword)
cmd.Parameters.Add(p_email)
cmd.Parameters.Add(p_shippingaddress)
cmd.Parameters.Add(p_errorMsg)
cmd.ExecuteNonQuery()
'MsgBox(p_email.Value.ToString())
txtFullName.Text = p_buyername.Value.ToString()
txtEmail.Text = p_email.Value.ToString()
txtAddress.Text = p_shippingaddress.Value.ToString()
conn.Close()
End If
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
'getf("txtFullName")
MsgBox(txtFullName.Text)
writeToF("txtFullName", "hahahaha")
MsgBox(txtFullName.Text)
'ASPNET_MsgBox(txtFullName.Text.)
'ASPNET_MsgBox("=" & Request()
'Dim key As String
'For Each key As String In Request.ServerVariables.AllKeys
'ASPNET_MsgBox(key & ": " & Request.ServerVariables(key))
'Next
Select Case txtcPassword.Text
Case ""
If txtNewPassword.Text <> "" Or txtNewPasswordConfirmation.Text <> "" Then
ASPNET_MsgBox("you need to enter your current password in order to change to a new one!")
Else
conn.Open()
Dim cmd As New OracleCommand(sql, conn)
p_errorMsg = New OracleParameter("pErrorMsg", OracleDbType.Varchar2, ParameterDirection.Output)
p_userid = New OracleParameter("p_userid", OracleDbType.Decimal, ParameterDirection.Input)
p_buyername = New OracleParameter("p_buyername", OracleDbType.Varchar2, ParameterDirection.Input)
p_email = New OracleParameter("p_email", OracleDbType.Varchar2, ParameterDirection.Input)
p_shippingaddress = New OracleParameter("p_shippingaddress", OracleDbType.Varchar2, ParameterDirection.Input)
p_ipassword = New OracleParameter("p_ipassword", OracleDbType.Varchar2, ParameterDirection.Input)
cmd = New OracleCommand("update_buyerProfile", conn)
cmd.CommandType = CommandType.StoredProcedure
' declaring sizes of the db vars
p_userid.Size = 6
p_buyername.Size = 50
p_ipassword.Size = 50
p_shippingaddress.Size = 100
p_email.Size = 100
p_errorMsg.Size = 100
p_userid.Value = userid
p_ipassword.Value = p_opassword.Value
p_shippingaddress.Value = txtAddress.Text
p_email.Value = txtEmail.Text
p_buyername.Value = txtFullName.Text
'(p_userid IN integer, p_buyername in varchar2, p_shippingaddress in varchar2,
'p_email in varchar2,p_ipassword in varchar2, pErrorMsg OUT varchar2)
cmd.Parameters.Add(p_userid)
cmd.Parameters.Add(p_buyername)
cmd.Parameters.Add(p_shippingaddress)
cmd.Parameters.Add(p_email)
cmd.Parameters.Add(p_ipassword)
cmd.Parameters.Add(p_errorMsg)
'ASPNET_MsgBox(p_userid.Value.ToString() & "," & p_buyername.Value.ToString() & "," _
'& p_shippingaddress.Value.ToString() & "," & p_email.Value.ToString() & "," _
'& p_ipassword.Value.ToString() & "," & p_errorMsg.Value.ToString())
'txtFullName.Text = "eeeeeeeeeeee"
'Dim t As String = p_opassword.Value.ToString()
cmd.ExecuteNonQuery()
'ASPNET_MsgBox(p_errorMsg.Value.ToString())
conn.Close()
End If
Case p_opassword.Value.ToString()
Case Else
ASPNET_MsgBox("Sorry, you have not entered the correct password ! <br> You may try to enter it again !")
End Select
End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="BuyerProfile.aspx.vb" Inherits="loginForm.BuyerProfile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Buyer Control Panel</title>
<link rel="stylesheet" type="text/css" href="1st.css" />
</style>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
}
.style3
{
width: 187px;
}
.style4
{
height: 15px;
}
.style5
{
width: 187px;
height: 15px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div align="center" id="mainDiv">
<table id="mainTbl" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="2" id="headerCell">
<table cellpadding="0" cellspacing="0" style="width:100%; height:71px;">
<tr>
<td id="lTop">
</td>
<td id="mTop">
</td>
<td id="rTop">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table id="mnuTbl" cellpadding="0" cellspacing="0">
<tr>
<td>
View Cart</td>
</tr>
<tr>
<td>
Order Status</td>
</tr>
<tr>
<td>
Orders History</td>
</tr>
<tr>
<td>
<a href="BuyerProfile.aspx">Edit Profile</a></td>
</tr>
<tr>
<td>
Log out</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
<td class="rightCol">
<table id="ttt" class="style1">
<tr>
<td align="center" colspan="3" style="text-align: justify">
</td>
</tr>
<tr>
<td class="style4">
</td>
<td class="style5">
Full Name:</td>
<td class="style4">
<asp:TextBox ID="txtFullName" runat="server" Width="251px"
EnableViewState="False"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style3">
Current Password:</td>
<td style="direction: ltr">
<asp:TextBox ID="txtcPassword" runat="server" Width="250px" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style3">
New Password:</td>
<td>
<asp:TextBox ID="txtNewPassword" runat="server" Width="250px"
TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style3">
New Password confirmation:</td>
<td>
<asp:TextBox ID="txtNewPasswordConfirmation" runat="server" Width="249px"
TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style3">
Email:</td>
<td>
<asp:TextBox ID="txtEmail" runat="server" Width="249px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style3">
Shipping address:</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Width="247px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" class="style2" colspan="3">
<asp:Button ID="btnUpdate" runat="server" Text="update" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>