Server Controls/SQL Update Statement

  • Thread starter Craig Feise via .NET 247
  • Start date
C

Craig Feise via .NET 247

Try to bear with me while I paint the stage for my problem, Ihope someone can shed some light.

I am coding a CRM (Customer Relationship Management) applicationusing ASP.NET coded in VB.NET using a SQL Server backend.
A customer is added to the DB and the user is forwarded to aValidation page via Response.Redirect with a customer IDattached to the URL so the user can check to ensure what wasjust entered is infact accurate beyond the server controlsvalidation. Meaning I dont check for proper spelling and such,just that text is where text belongs and integers are where theybelong.

The validation page consists of identical textbox server controlsand dropdown menus. Since the new customer has already beeninserted into the DB, the customer ID is taken from theRequest.QueryString and used to look up the newly enteredcustomers information from the customers table. This informationis then assigned to the text properties of the textbox's and theSelectedValue of the dropdown menus. These controls have theirenabled property set to False. They are only being used fordisplaying information.
If the user finds that he/she made an error in spelling or menuselection, there is a command button which will redirect theuser to an update page where the corrections can be made. Onceagain the customer ID is attached to a URL for the Update pageand the user is redirected via a Response.Redirect.

The update page again makes a call to the Database and pulls thecustomers information and fills another identical set oftextbox's and dropdown menus with the current customerinformation. This time the controls are enabled and the valuesare editable.
Finally, when the changes are made, the user clicks the "CommitChanges" command button on the update page which then createsthe appropriate SQLCommand and SQLConnection objects, assigns aTSQL Update command to the SQLCommand objects CommandTextproperty and using the SQLCommand objects ExecuteNonQuerymethod, is supposed to update the customer information using aWith clause containing the customerID.
Now that you can see the stage, the problem is that the Updatecommand is not updating the information contained in thecustomers? table when a change is made on the Update page. Afterplaying around with it I have found that when my TSQL Updatecommand does NOT make reference to the server controlsthemselves, the update occurs. Of course when it does, theUpdate doesnt happen.
Example. "Update Customers Set FirstName = 'Joe' where CustomerID= 12345" will update the database.
However. "Update Customers Set FirstName = '" & txtFirstName.Text& "' where CustomerID = " & Request.QueryString("ID")" does notwork and does not throw any SQL Exceptions. (I have aSQLException handler for that).

Would anyone have an idea why this is happening. With noexceptions being thrown, I'm at a bit of a loss.

Thanks in advance for any help you can offer.
If you would like to see the code, just leave me your e-mail andI'd be happy to send it along to you.

Craig
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top