Persistent UPDATE Problem

G

Guest

Hi there

I have had an application where I have not been able to successully add an 'update details page' for my clients logged in to the website.

I have posted a query on this before and the result was that the WHERE clause was probably wrong; without success....but I have added a test labels to test so now know a little more so hopefully you can help.

Have ASP.NET / SQL Server 2000. The web app has a members area which is https. i'm using authenication ticket which stores the member ID ref as a state variable called 'MemberRef'


So problem page....
When this UPDATE PERSONAL DETAILS page loads, it fills the textboxes on the page with a datareader according to who is logged in. One textbox example is as follows:

txtFirstName.Text = rdr("colFName")



Then of course I need a process so my members can update their personal details stored in the DB, so those text boxes allow updates and I've added a button which should update the DB

Private Sub ButUpdatePractice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Handles ButUpdatePractice.Click
Dim strCOMP As String
Dim conCOMP As SqlConnection
Dim cmdUPDATECOMP As SqlCommand
conCOMP = xxx

cmdUPDATECOMP = New SqlCommand(strCOMP, conCOMP)
strCOMP = "UPDATE ClientDetails SET colFName = @Fname WHERE MemberRef = @MemberRef"
cmdUPDATE.Parameters.Add("@Fname", txtFirstName.Text)
cmdUPDATE.Parameters.Add("@@MemberRef", MemberRef)
conCOMP.Open()
cmdUPDATECOMP.ExecuteNonQuery()
conCOMP.close

-now plrease ignore any misspellings above - done it for speed for this forum.

Now this doesn't update the DB when pressing the update button. It re-freshes the page. I've added a label to the page which shows the strCOMP update string on the page to test ( label1.text = strCOMP ) and it contains the existing value from the DB.

Please help.
 
F

Frans Bouma [C# MVP]

dazzalondon said:
Hi there

I have had an application where I have not been able to successully add an
'update details page' for my clients logged in to the website.

I have posted a query on this before and the result was that the WHERE
clause was probably wrong; without success....but I have added a test
labels to test so now know a little more so hopefully you can help.

Have ASP.NET / SQL Server 2000. The web app has a members area which is
https. i'm using authenication ticket which stores the member ID ref as a
state variable called 'MemberRef'


So problem page....
When this UPDATE PERSONAL DETAILS page loads, it fills the textboxes on the
page with a datareader according to who is logged in. One textbox example
is as follows:

txtFirstName.Text = rdr("colFName")



Then of course I need a process so my members can update their personal
details stored in the DB, so those text boxes allow updates and I've added
a button which should update the DB

Private Sub ButUpdatePractice_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) 'Handles ButUpdatePractice.Click Dim
strCOMP As String Dim conCOMP As SqlConnection
Dim cmdUPDATECOMP As SqlCommand
conCOMP = xxx

cmdUPDATECOMP = New SqlCommand(strCOMP, conCOMP)
strCOMP = "UPDATE ClientDetails SET colFName = @Fname WHERE MemberRef =
@MemberRef" cmdUPDATE.Parameters.Add("@Fname", txtFirstName.Text)
cmdUPDATE.Parameters.Add("@@MemberRef", MemberRef)

Shouldn't that be '@MemberRef' instead of '@@MemberRef' ?

FB
 
G

Guest

Soz, that was a typo being posted on here.

The problem I have is still there - the page refreshes when I hit the button, but DB isn't updated. please please help. this is a major major headache which has been bothering me and my client for months.

Like I said, I've placed a label on the page which fills with the update string, which fills with:

UPDATE ClientDetails SET colFName='graham' WHERE MemberRef = 100

BUT Graham is the value which is already on the screen - it should be the value of the text box which has been edited by someone on the screen.
please help
 
R

Ron Allen

If you have your code typed in the same order you aren't setting the
string with the CommandText for the command until after you create the
command so the command's text will be whatever this string contains at that
time which is probably nothing.
I'd also use the SqlParameter overload that specifies the SqlDataType of
the parameter to make sure that it wasn't being misinterpeted as that could
cause problems as well.

Ron Allen
dazzalondon said:
Hi there

I have had an application where I have not been able to successully add an
'update details page' for my clients logged in to the website.
I have posted a query on this before and the result was that the WHERE
clause was probably wrong; without success....but I have added a test labels
to test so now know a little more so hopefully you can help.
Have ASP.NET / SQL Server 2000. The web app has a members area which is
https. i'm using authenication ticket which stores the member ID ref as a
state variable called 'MemberRef'
So problem page....
When this UPDATE PERSONAL DETAILS page loads, it fills the textboxes on
the page with a datareader according to who is logged in. One textbox
example is as follows:
txtFirstName.Text = rdr("colFName")



Then of course I need a process so my members can update their personal
details stored in the DB, so those text boxes allow updates and I've added a
button which should update the DB
Private Sub ButUpdatePractice_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) 'Handles ButUpdatePractice.Click
Dim strCOMP As String
Dim conCOMP As SqlConnection
Dim cmdUPDATECOMP As SqlCommand
conCOMP = xxx

cmdUPDATECOMP = New SqlCommand(strCOMP, conCOMP)
strCOMP = "UPDATE ClientDetails SET colFName = @Fname WHERE MemberRef = @MemberRef"
cmdUPDATE.Parameters.Add("@Fname", txtFirstName.Text)
cmdUPDATE.Parameters.Add("@@MemberRef", MemberRef)
conCOMP.Open()
cmdUPDATECOMP.ExecuteNonQuery()
conCOMP.close

-now plrease ignore any misspellings above - done it for speed for this forum.

Now this doesn't update the DB when pressing the update button. It
re-freshes the page. I've added a label to the page which shows the strCOMP
update string on the page to test ( label1.text = strCOMP ) and it contains
the existing value from the DB.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top