Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Access table with ASP.net

Status
Not open for further replies.

ktb916

Programmer
Jan 22, 2004
76
US
I'm trying to create an ASP website that displays data from an access database. I have been able to get the data but I also want to be able to write changes back to the table. I have the edit option checked in the grid view properties but apparently there isn't any underlying code to write back to the database. Can anyone point me in the right direction?

Thanks
 
So can I just write an SQL statement or is it more complicated with ASP
 
Would you mind to give me a code sample to go by?
 
So can I just write an SQL statement
Yes, and then just execute it from your ASP.NET page. Follow the steps that Jason provided you above.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Hi, I've done a little work and created a dataset to work with my access database information. It updates now which is great but it updates all the fields I selected in the original query instead of just the one I changed which would be fine if it just wrote back duplicate information but it overwrites with an empty string - not good - any ideas?
 
either
1. instruct the grid to return all the values that were originally loaded.
2. manage the update statement to only update that specific field.

the way I usually handle these situations is by that single entity, updating the appropiate properties, and saving the object.

I haven't used TableAdapters and DataSet in ages, but it would look something like this

The dataset would define the entity(s)
DataTables
Customer
CustomerAdapter
GetAllCustomers() returns Customer table
GetCustomerBy(int id) returns CustomerRow

From the GUI on page load you would GetAllCustomers().
then to update you would GetCustomerById(selectedId). update that row and then call update on the table adapter. i don't know the exact syntax for all this but it gets you started.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hi I dropped the ball on this a few weeks ago and am trying to get started again. Since you don't use tableadapters and so forth what do you use? To be honest your last thread was way over my head. If there is an easier method I'd rahter go that route.

Thanks
 
i use ORMs (object relational mappers). NHibernate (NH) is very powerful but comes with a steep learning curve. This tool is awesome for unit testing and SOC (seperation of concerns). ActiveRecord is built on top of NHibernate. It uses Class/Member attributes to map domain objects to database tables. easier than NH but still requires configuration and some OOP skills. LLBL is another ORM($) this is the very M$ RAD friendly (not so unit test friendly). the product includes a wizard to map databases to objects for you automatically. M$ is about to release EntityFramework.

I am now using NH in all my projects since it's so easy to unit test and completely sperates data access from the domain.

if my last post was over your head you need to research ADO.Net and strongly typed datasets. this can be the foundation of a DAL (data access layer).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top