Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2010, 04:33 AM
Authorized User
 
Join Date: Apr 2009
Posts: 48
Thanks: 16
Thanked 0 Times in 0 Posts
Default inserting checkboxlist items into the database

Hello Imar,

I had a similar problem as Julian Fraser in his post from the 4th of November 2009. again here my scenerio is similar to the try it out on 572, but then again not...
The scenerio is like this; I have 2 tables, Accomodations and Facilities, with a many - many, relationship that I devided into 2 one-many relationships by making a 3rd table that holds 2 Fkeys (AccId and FacId), that make up the composite primary key; AccFacilities.
So to assign certain Facilities to an Accomodation, I made a form with a checkboxlist that gets its data from Facilities, (this checkboxlist resides inside a repeater that gets its data from the FacilityType table).

So for each checked box I now have to insert a record in the AccFacilities table, and all in code behind i guess...
I looked for a clue in different forums until i stumbled upon Julians post and started reading the links you send him.

So my question is; do I have to resolve this issue with ADO.Net or is there a simpler way to go about it?

(ADO.net might be simple too, but sofar it looks like abacadabra, I have the wrox ASP.NET 3.5 professional, but before I dive into ADO, I was just looking for a confirmation that at least the direction of my search is correct)

thanks, Robin
 
Old February 5th, 2010, 04:42 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It would help if you posted the link, so I don't have to go search through 252,458 posts to go find it ;-)

That said, the answer is: it depends. ADO.NET is a useful thing to learn as you'll probably need it someday, one way or the other.

But there are alternatives. For example, Microsoft's Entity framework enables you to do something like this:
Code:
 
Accomodation myAccomodation = new Accomodation();
myAccomodation.Facilities.Add(new Facility(){ Name = "SomeName"});
myAccomodation.Facilities.Add(new Facility(){ Name = "SomeOtherName"});
// Save changes here
In other words, it's designed to interact with the database through an object model that shields you from some of the underlying database design decisions as foreign keys and many to many relations. Linq to SQL does not support this well, but EF does.

There are also other ORM frameworks available that help you with this. And, with a bit awkward code, you can even do it with Linq to SQL.

So, the answer is: it depends. Pure ADO.NET would work well but requires some knowledge. Other frameworks exist, but you need to learn how they work as well.

Not a concrete answer, but it all depends in the direction you want to go to and the knowledge you already have.

To give you an idea of what ADO.NET and SQL code looks like, you may want to check out my article series on N-Layered design with ASP.NET 3.5: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=476

Cheers.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
robbaralla (February 5th, 2010)
 
Old February 5th, 2010, 05:07 AM
Authorized User
 
Join Date: Apr 2009
Posts: 48
Thanks: 16
Thanked 0 Times in 0 Posts
Default

Ok, thanks for your very helpfull answer and my excuses for making you search through those posts.

I'm fresh Imar, started with your book, so I'm taking it from there. As there seem to be more technologies around the net then trees in the forest, I just wanted some direction to point my nose in, something usefull for the future (of building portals) also.
So it seems that ADO.NET is the thing to learn, right?
I'll start with following the link to your site and see where it takes me.

Best regards, Robin
 
Old February 5th, 2010, 05:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

My article may not be the best place to start as it assumes working knowledge of ADO.NET and more. I merely referenced it so you can see what kind of code you need to write once you start using ADO.NET.

For a beginners guide in ADO.NET, take a look here: http://quickstart.developerfusion.co...wcontents.aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
robbaralla (February 5th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting CheckBoxList selected items to database julianfraser BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 November 4th, 2009 04:43 PM
check n uncheck items in checkboxlist in datalist moorejkrkumar ASP.NET 1.0 and 1.1 Basics 1 April 17th, 2007 01:39 PM
Check all Checkboxlist items on client-side avilren ASP.NET 1.0 and 1.1 Basics 2 July 9th, 2006 10:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.