From String... to Variable... to Listbox [Newbian looking for help]
Hello all, thanks for reading. I am trying to learn C# and have picked up a lot very quickly by reading tutorials, watching videos, using boards, and writing a practice piece. I am currently stuck on a problem... // ... I have a form that shows details of Operatives. On that form has a listbox where I have a list of skills that the operative has. This list needs to be add to by the User. Also this list will be searchable later in the programme. I have come up with a comma deliminated string. With the code |__|CODE|__| char[] splits = { ' ', ',' }; |__|CODE|__| to help split up the deliminated entries. This works fine, but I would like the string to get its information from the database table, and in reverse have any selection saved back to the database. <.....> QUESTION: How can I have my Variable call a specific field in an sql database table that currently holds a string of comma deliminated text (nvarchar). <.....> ATTEMPT : |__|CODE|__| str = Database1DataSet.OperativeDataTable.Equals ("Skills"); |__|CODE |__| needless to say this idea didn't work, but I simply cannot work out the correct syntax, I'm convinced however that it is achievable. Thank you for your help I very much appreciate your time and effort.
Sam HobbsPosted Nov 22, 2009, 9:49 AM
As for how to add skills, then your program can simply do a lookup for a skill and if the skill is not found, just add the skill.
Paul ChambersPosted Nov 22, 2009, 12:49 PM
Paul ChambersPosted Nov 22, 2009, 4:51 AM
Sam HobbsPosted Nov 21, 2009, 6:50 PM
I will try to explain what is the best way to do this if the developer is familiar with databases. I assume that the skills are a specific list of skills; that is, that there are generally skills that apply to many (not all) operatives. You should have a table that lists each skill and then the rows for each operative would relate to the skills. You can use a database such as Access to learn about creating tables with relationships. It is more work doing the relationships, but it is also more powerful. When you relate the data, it is easier to do things such as list all the operatives with a specified skill.
Data relationships are very common; in a database of books, a book might have a specifed list of subjects and one or more authors. By relating the data, it is possible to find all books with a specifed subject or with a specified author.
Paul ChambersPosted Nov 21, 2009, 4:59 PM
Sam HobbsPosted Nov 21, 2009, 1:50 PM
If you are storing in a database table, the normal way to do it is to store each operative in a separate row of a table.
See Data Walkthroughs to get an idea of what you can do. Don't do all the walkthroughs; do the ones that appear to relate to what you are doing. Those walkthroughs will show you how to use Visual Studio (VS) interactively.
The answer to the question "How can I have my Variable call a specific field in an sql database table" depends on what you need to do with the data.