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 423,531 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 4,338 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: 908 | Replies: 4 | Solved
Reply
Join Date: Dec 2007
Location: Switzerland
Posts: 3
Reputation: erichn is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
erichn erichn is offline Offline
Newbie Poster

Question Database design - ASP.NET MsAccess

  #1  
Dec 8th, 2007
I am stuck to know how to design a database for an asp.net 2.0 project.

I have a table with many fields. In addition to all the other fields (mainly text fields) I would like to keep track of 4 values: alt, sy, LaF, ord.
Any combination of these values is possible. For most records, none of these values would be applicable, meaning nothing should display.

In most queries I would like to display simply these values, seperated by a space, preferably under one heading.
..... MyCodes
..... alt
..... sy ord.
..... LaF ord.
..... alt LaF
..... LaF
..... alt LaF ord. sy
.....
..... ord.

But in my input form, I would like to use checkboxes for these fields.

I never need to make a selection on these fields, they are simply additional information to be displayed.

I fiddled with 4 boolean fields - which allowed me to set the values into the database from the form. However I could not find a way to display them the way I want to (see above).

I also fiddled with 4 different text fields, each one always using the same value in the field. e.g. FieldAlt = "alt". This allowed me to display the values the way I want - but I was unable to update the fields from checkboxes. ("String was not recognized as a valid Boolean." error messages)

Anybody has some suggestions?
Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 102
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Database design - ASP.NET MsAccess

  #2  
Dec 8th, 2007
if those are the only codes that you'll be using, couldn't you just use string concatenation on it? Ie, if you had one that was "alt LaF" would could just input that in as a string.

From that standpoint, when you updated it, you would have to make sure that you updated ALL of it, ie, if you wanted to change "alt LaF" to "alt sy ord." ,you would want to make sure that each value is explicitly updated when you do it.

Does that make sense? Otherwise, you'd need to set up a normalized database, with a row representing each code that applied to that bit of data, joined together.
Alex Cavnar, aka alc6379
Reply With Quote  
Join Date: Dec 2007
Location: Switzerland
Posts: 3
Reputation: erichn is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
erichn erichn is offline Offline
Newbie Poster

Re: Database design - ASP.NET MsAccess

  #3  
Dec 8th, 2007
I have used this approach and I managed to do everything I wanted, except I was not able to use checkboxes to insert and update the fields.

So if you have a solution to that problem, it would be my preferred design as well.

Thanks
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 102
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Database design - ASP.NET MsAccess

  #4  
Dec 9th, 2007
you could use a set of if statements or something.

basically,

string myValues = "" //initialize the string

if (chkAlt.Checked == true)
{
       myValues = myValues + " Alt";
}

//...and so forth

Then, you'd create an OleDBCommand or SqlCommand that contained the ID. Something like:

"UPDATE tbl_values SET columnName = " + myfield + " Where ID = " + myRow; 

You still need to figure out what your ID is. But, that code I just gave you is what the CommandText of your SqlCommand or OleDbCommand might look like. Then, you'd run the ExecuteNonQuery() of your command. That should commit it to the database.
Alex Cavnar, aka alc6379
Reply With Quote  
Join Date: Dec 2007
Location: Switzerland
Posts: 3
Reputation: erichn is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
erichn erichn is offline Offline
Newbie Poster

Re: Database design - ASP.NET MsAccess

  #5  
Dec 10th, 2007
Thanks very much for your input. I have opted for 4 boolean fields in the database and use something similar to your code
string myValues = "" //initialize the string

if (chkAlt.Checked == true)
{
myValues = myValues + " Alt";
}
to display the values in my grid control.

Works like a dream!
Reply With Quote  
Reply

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

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ASP.NET Forum

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