6 Replies - 301 Views - Last Post: 15 October 2011 - 11:22 AM Rate Topic: -----

#1 Drega  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-October 11

Help with database fill

Posted 15 October 2011 - 07:59 AM

Hello all,

Working on an application as a database reader. It has three forms, and my problem lies with the second. The first is able to pull the data easily enough en-masse from my database into a gridview to show everything. The second is a more easy to read form shown below:

Posted Image

As you can see it contains comboboxes and textboxes. I have my data there ready to be shown, dataset etc is all on the form, i have the comboboxes linked to the data set. What i need to do is get the database to fill all of the text/combo boxes, with the data obviously changing on different people. What i can't seem to work out is what i need to write. I have spoken to a friend who said what i need to do is write an SQL query that will select the row i want and fill it, which requires a separate fill per each item.

What i'd like to know is:

1) Is this correct
2) A nudge in the right direction if it is or if it isn't.

I have tried to write the SQL query but it hasn't come out correctly as i can't seem to figure out the last requirement (WHERE clause), have tried looking through my notes and ADO.net with C# 2008 book, as well as online but nothing jumps out at me or seems to help me.

Any help would be greatly appreciated. Please note i am not asking anybody to do this or for specific code, just a nudge or an explanation that could help me understand.

Is This A Good Question/Topic? 0
  • +

Replies To: Help with database fill

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,819
  • Joined: 12-June 08

Re: Help with database fill

Posted 15 October 2011 - 10:42 AM

Yes - if your drop downs are conditionally filled by the patient info then you'll need separate queries for each.

How is your database structured? Tables, keys, relations, etc?
Was This Post Helpful? 0
  • +
  • -

#3 Drega  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-October 11

Re: Help with database fill

Posted 15 October 2011 - 10:53 AM

Yes they are, i assume the same for Textbox also? Is there anywhere i can find a guide or examples so i get a rough idea on what to code?

Single database:

Posted Image

Two of them but both refer to same DB, one for the first form next for the second (figure i might have done that wrong but this is my first attempt at building something like this).

Just want each text and dropdown to be filled by the information present in the DB when accessed.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,819
  • Joined: 12-June 08

Re: Help with database fill

Posted 15 October 2011 - 11:02 AM

You'll have to read up on 'relational databases'. The gist is you have simple tables with a unique key and a string value. Those keys would gathered in another table for the person or patient.

In your case you would have a table that lists out mental health strings and has a unique id for each line... the same with physical disabilities...

Then you would have a patient table that has a unique id, their name, address, phone number, etc, and a column for a mental health id, and one for the disability id. this is called a foreign key relationship.

The gist would be you would fill your drop downs with the data in their tables, then load the user information. When it comes to the mental health and physical disability key values you would set the drop downs to that specific key so it shows the text in the box.

This breaking apart of information into contained tables and using foreign keys is generally called 'normalizing' of a database.
Was This Post Helpful? 0
  • +
  • -

#5 Drega  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-October 11

Re: Help with database fill

Posted 15 October 2011 - 11:04 AM

Aye sounds familiar to what I've done before. So i need to get a different table for each thing i need to fill? ie:

Mental health problems
Gender
etc
etc
etc

And link them into each bit that i want via the Query builder?
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,819
  • Joined: 12-June 08

Re: Help with database fill

Posted 15 October 2011 - 11:12 AM

What do you mean 'link them into each bit'? I wouldn't recommend a join.. as I said.. you would load and fill each little table, but when it comes to the main user id table set the value of your drop downs to the foreign key value stored in the user id information.
Was This Post Helpful? 0
  • +
  • -

#7 Drega  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-October 11

Re: Help with database fill

Posted 15 October 2011 - 11:22 AM

Ok, anywhere you can link me to for reference to read?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1