Simply i have a textbox that my users will enter in a Fan rpm. I need my program to take the entered fanrpm and compare it with a database item called classrpm. My query from the database Will only return 1 item ever.
I need fanrpm to be > classrpm, and if fanrpm >= class rpm a msg box to pop-up and state "Fan RPM exceeds ClassRPM(which is x), please enter a value under ClassRPM.
The code below was my test with fake variable names. I attempted to take and convert the user entered text and the database retrieved item, then using the converted values to do the above if statement, and then output a msg box to inform me if it succeeded.
private void textBox1_TextChanged(object sender, EventArgs e)
{
txfanrpm.MaxLength = 4
string classrpm;
string fanrpm;
using (Fanrpm ds = new Fanrpm(cbdesigntype.SelectedValue.ToString(), cbfansize.SelectedValue.ToString(), cbfanclass.SelectedValue.ToString()))
{
DataTable dt = ds.dataset.Tables[0];
List<string> coolList = new List<string>();
foreach (DataRow row in dt.Rows)
{
coolList.Add(row[0].ToString());
}
classrpm = coolList.ToString();
fanrpm = txfanrpm.Text.ToString();
int classrpmInt;
int fanrpmInt;
classrpmInt = Convert.ToInt32(classrpm);
fanrpmInt = Convert.ToInt32(fanrpm);
if (fanrpmInt >= classrpmInt)
{
MessageBox.Show(this, "user entered fanrpm higher then class rpm which is yadda yadda");
}
else if (fanrpmInt < classrpmInt)
{
MessageBox.Show(this, "Fanrpm is less then Classrpm");
}
}
}
I believe my problem stems in converting my database item into something usable to compare too. Also i think that if my setup works as intended it may tell a user entering 500 at each entry the textbox will refresh and redo the query leading to potential wasted processing power?
-Edit my sql statement works, Though putting the data into a list may be one of my problems.