I have a C# winform app, that contains a formula. The formula works ok but depending on the id from a SQL table the numbers in the formula can change.
How can I accomplish this?
The code I have is:
private void button1_Click(object sender, EventArgs e)
{
decimal ufa1;
decimal aav1;
decimal uft1;
ufa1 = uft1 * aav1 * VALUE FROM SQL;
}
I have a previous query that gets the value I want but I can't get it integrated in the formula.
The code to get the id is:
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select prumos from dbo.modelos where id = '"+id+"'";
SqlDataReader dr = cmd.ExecuteReader();
new code: Because of dependencies i had to change the select from id to a column named "prumos" with int values just like id but it wont run.
con.Open();
using (SqlCommand cmd = new SqlCommand("select prumos from dbo.modelos where prumos = @prumos", con))
{
cmd.Parameters.Add(new SqlParameter("prumos", prumos));
ValueFromDB = decimal.Parse(cmd.ExecuteScalar().ToString());
}
any solutions?