?
Solved

Pick Database field from asp.net page and save them

Posted on 2012-03-22
7
Medium Priority
?
378 Views
Last Modified: 2012-03-22
Ok here is what I am trying to accomplish, I have a table with lots of fields for registration of different products.  Each time they add a new product they want to be able to save the fields that they want to fill out in a db so that I do not have to hard code them each time with code.  So how can users pick which DB fields they want to save information agianst and save in table so that when they go to the page it pulls up only the fields that they picked to fill out?

So they add a product called WIFI
WIFI has the following properties that they want to capture
IP,
dataplan,
range
carrier
so they pick these fields from the registration table and save to antoher table that keeps the fields they picked so when they open the page it only shows the fields they picked.

IS this doable and can someone give me some guidlines on how to do and I can figure out most from there.
0
Comment
Question by:kdeutsch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 38

Assisted Solution

by:PaulHews
PaulHews earned 400 total points
ID: 37753266
I would say you want a table for Product, with an extra table for ProductDataColumn

ProductDataColumn
Name
<Any other fields you need to describe or validate the data>

Relation:
Product one to many ProductDataColumn


You also need a table to store the data.  
ProductData:
ID
ProductID  (FK to Product)
ProductDataColumnID (FK to ProductDataColumn)
Data

Product one to many ProductData (each column has it's own row.)  Obviously you have to store all the extra data as strings, so converting where needed.
0
 
LVL 9

Accepted Solution

by:
gery128 earned 1600 total points
ID: 37753335
I could think this way only to achieve this:
(Lets say Table name is Product and you need to allow most of the field as Null)
1. Display all the fields of Product-table to user (using InformationSchema - ColumnName)
2. User will check fields relevant to it. And will click next.
3. Now you have user's choice about the Product-table fields (say, for WIFI he has chosen
IP,
dataplan,
range
carrier
but he ignored weight, length, type, resolution etc.)
So you will forward this chosen fields to next page and populate text-boxes, drop-downs or other controls for that fields with Labels off-course.
4. Once user fills, you will save/insert those 4-5 fields in Product table as record, inserting only relevant columns and ignoring the rest of it (that's why we need keep most of the fields null except ProductId or Unique key for that record.)
5. You have record in Product table, display it to user by checking which column has data and populate only those labels to show it to user.

Let me know if it fulfills your criteria.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 37753422
The only problem with gery128's solution is that you have to know all the field types in advance.  Otherwise you will be updating the columns on that table whenever you encounter a product that has a new feature/specification.  If that's okay, then that's the way to go.

On the other hand, my approach treats the extra columns as data, so you can add columns without refactoring the database structure when you want to add a new product with different features that need to be listed.
0
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 

Author Comment

by:kdeutsch
ID: 37753767
Hi,
The database is  already predetermined based of off the characteristics of IT products,  so when they insert a new IT Product they pick and save the fields from the DB they plan on using, so that it pops up on the page each time they go to it.  Then they can save the data and move on.
So it sounds like I can query the schema of a table and from here they will need to save which ones they pick into another db as the chosen fields from which the page will load these fields and tehn save the data to the table.
0
 

Author Comment

by:kdeutsch
ID: 37753796
Ok,
Just so I am on right track, I found out how to query the table Schema, now I need to pick the columns I want, and then save these columns in another DB with the product and its accompany fields names from which I will query to put textboxes on the asp page which allows them to save the data.  Right track or wrong.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 37753921
Sounds like you are on track for the approach suggested by gery128.  It's certainly a good way to approach the problem.
0
 

Author Closing Comment

by:kdeutsch
ID: 37754678
Thanks for the good start, i have it all selecting and saving in a table. Next the harder part.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question