G
Guest
I'd like to clear up a very long-standing problem I have had only because I have done a little more testing, but the problem is still there.
On Page_Load event, the textfields on my page fills with the personal data stored in a SQL DB, as follows:
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim rdr As SqlDataReader
cn = New SqlConnection("xxx")
cn.Open()
cmd = New SqlCommand("SELECT SName FROM ClientDetails WHERE clientRef=100", cn)
rdr = cmd.ExecuteReader()
rdr.Read()
'fill the surname textbox
txtSName.Text = rdr("ColSurName")
cn.Close()
e.g. pretend the value of the colSurNamel in the DB is 'Smith'
Then on the form my clients can update their details by simply overwriting the text in the textboxes and hitting the UPDATE button.
Assume I have now updated the textbox with 'Bloggs' and I've hit the UPDATE button (code as follows):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conCOMP As SqlConnection
Dim cmdUPDATECOMP As SqlCommand
conCOMP = New SqlConnection("xxxxxx")
strCOMP = "UPDATE ClientDetails SET colSurName= '" & txtSName.Text & "' WHERE ClientRef = 100"
cmdUPDATECOMP = New SqlCommand(strCOMP, conCOMP)
Label4.Text = strCOMP
conCOMP.Open()
cmdUPDATECOMP.ExecuteNonQuery()
conCOMP.Close()
End Sub
I've added a label here to view the value of the UPDATE command when it is passed BUT it gives the value already stored in the DB / or rather the value it already got in the Page_Load routine:
the text in Label4 is: " UPDATE ClientDetails SET colSurName = 'Smith' WHERE ClientRef = 100 "
I think it is obviously the text box variable: having got a value for when the Page_Load event occurs. But how can my clients change the text boxes to update their details and hit UPDATE??????
PLEASE PLEASE HELP. This seriously has been BUGGing me for a month. My Client is not happy
On Page_Load event, the textfields on my page fills with the personal data stored in a SQL DB, as follows:
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim rdr As SqlDataReader
cn = New SqlConnection("xxx")
cn.Open()
cmd = New SqlCommand("SELECT SName FROM ClientDetails WHERE clientRef=100", cn)
rdr = cmd.ExecuteReader()
rdr.Read()
'fill the surname textbox
txtSName.Text = rdr("ColSurName")
cn.Close()
e.g. pretend the value of the colSurNamel in the DB is 'Smith'
Then on the form my clients can update their details by simply overwriting the text in the textboxes and hitting the UPDATE button.
Assume I have now updated the textbox with 'Bloggs' and I've hit the UPDATE button (code as follows):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conCOMP As SqlConnection
Dim cmdUPDATECOMP As SqlCommand
conCOMP = New SqlConnection("xxxxxx")
strCOMP = "UPDATE ClientDetails SET colSurName= '" & txtSName.Text & "' WHERE ClientRef = 100"
cmdUPDATECOMP = New SqlCommand(strCOMP, conCOMP)
Label4.Text = strCOMP
conCOMP.Open()
cmdUPDATECOMP.ExecuteNonQuery()
conCOMP.Close()
End Sub
I've added a label here to view the value of the UPDATE command when it is passed BUT it gives the value already stored in the DB / or rather the value it already got in the Page_Load routine:
the text in Label4 is: " UPDATE ClientDetails SET colSurName = 'Smith' WHERE ClientRef = 100 "
I think it is obviously the text box variable: having got a value for when the Page_Load event occurs. But how can my clients change the text boxes to update their details and hit UPDATE??????
PLEASE PLEASE HELP. This seriously has been BUGGing me for a month. My Client is not happy