November 27th, 2012, 09:57 AM
Help using SQL in C#
I'm a bit new to C# and brand new to SQL. I've been playing around with Visual Studio 2010 for a few weeks now and my few years of C++ back in my college years makes C# not too much of a pain to learn. I've run into a bit of a problem now though, my knowledge of SQL is near none. Let me try to explain what I'm trying to do first
I'm writing a program to help me at work. At my job we have many (~100) tools called PModules and each has a bunch of information tied to them. Now at first my basic understanding of programming got me thinking I could make a PModule class and make a ton of PModule objects. Something along the lines of:
public PModule(string iSN, string iLoc, int iNumChambers)
string SN = iSN;
string loc = iLoc;
int numChambers = iNumChambers;
PModule J01 = new PModule("H0125", "Bay C, 3rd PM on the right", 4);
PModule J06 = new PModule("H0173", "Bay D, 1st PM on the left", 6);
Now I've looked into it and realized I can have an SQL database with columns that hold all this info. I've watched a dozen YouTube videos and read a bunch of tutorials but I can't figure out how to do exactly what I'm trying to do, they all seem to dump the whole database on a form. All I've basically figured out from these that helps me is how to make a database. What I want to try to do is search the database, which I'm guessing I could do with a loop For Loop. Say I want to find PModule J01...
for (int i = 1; i <= lenghtOfDB; i++)
if (db.id(i).PModuleName == "J01")
found = true;
Now I'm not sure how to get the length of the database, which would be the condition as it counts through the IDs, then however you call that column that has the names and would check it till I found it. Once I found it I would like to make, say, textBox1.text = the number of chambers.
In the end I'm looking at making a drop down that has all these PMs (J01, J02, J03) then when they select one, they can hit a button that says Get Number of Chambers and a textBox will be set to have that number. Sorry for my ignorance and long winded'ness here but I'm at my wits end and I wanna make sure I cover all my bases. Thanks a ton for any information that can help me out here.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!