Help with using SQL in C#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hey guys,
<span class="x_x_x_Apple-tab-span" style="white-space:pre Im a bit new to C# and brand new to SQL. Ive 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. Ive run into a bit of a problem now though, my knowledge of SQL is near none. Let me try to explain what Im trying to do first

Im 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:
<pre class="prettyprint" style=" 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);
<br/>[/code]
Now Ive looked into it and realized I can have an SQL database with columns that hold all this info. Ive watched a dozen YouTube videos and read a bunch of tutorials but I cant figure out how to do exactly what Im trying to do, they all seem to
dump the whole database on a form. All Ive 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 Im guessing I could do with a loop For Loop. Say I want to find
PModule J01...
<pre class="prettyprint" style=" for (int i = 1; i <= lenghtOfDB; i++)
{ if (db.id(i).PModuleName == "J01") { found = true; break; } } [/code]
Now Im 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 Im 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 windedness
here but Im 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.
<br/>
<br/>

View the full article
 
Back
Top