User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,571 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,806 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 374 | Replies: 2
Reply
Join Date: Dec 2004
Posts: 37
Reputation: mindfrost82 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mindfrost82 mindfrost82 is offline Offline
Light Poster

Fill Textbox w/ DataReader from Access and allowing user's to update

  #1  
Jul 14th, 2008
I have an Access database and I want to fill some text boxes with data from a table. I'm using the following method for an example:

Me.txtCompany.Text = dr.GetString(1)

That works great. I have that in the PageLoad event.

Then I want a user to be able to change that value and submit it and have it update the database field.

So to do that, I have something like this:

strSQLCompany = "UPDATE Customers SET CompanyName='" & txtCompany.Text.Replace("'", "_") & "'"

This, however, doesn't work. It updates the database with the data that's entered into the text boxes on PageLoad instead of what's typed. I have the above code in my button click event.

I've tested my button click event by taking out the fill code in the PageLoad (making empty text boxes) and filling them in and submitting it and the correct information gets updated in the database, so I know that part of the code is correct.

Is there a reason why the button click event is taking the text from PageLoad instead of what's actually typed in the text box?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 37
Reputation: mindfrost82 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mindfrost82 mindfrost82 is offline Offline
Light Poster

Re: Fill Textbox w/ DataReader from Access and allowing user's to update

  #2  
29 Days Ago
*bump* anyone?
Reply With Quote  
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 86
Reputation: Kusno is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 6
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster in Training

Re: Fill Textbox w/ DataReader from Access and allowing user's to update

  #3  
28 Days Ago
Have you written your code in IsPostBack method ?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
   Me.txtCompany.Text = dr.GetString(1)
End If

Protected Sub CmdSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdSave.Click
Dim strSQLCompany  as String
strSQLCompany = "UPDATE Customers SET CompanyName='" & txtCompany.Text.Replace("'", "_") & "'"    
End Sub

Thanks,

Kusno.
NEVER NEVER NEVER GIVE UP
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 10:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC