Why is this not returning a number? I am trying to take a the price from the column "NFF" of the "MFD" row and return it as the textbox text.
private void button1_Click(object sender, EventArgs e)
{
string command = "SELECT NFF FROM dbo.Prices WHERE Item ='MFD'";
try
{
SqlConnection SQLCON = new SqlConnection(Properties.Settings.Default.PricesConnectionString);
SQLCON.Open();
SqlCommand SQLCommand = new SqlCommand();
SQLCommand.CommandType = CommandType.Text;
SQLCommand.CommandText = command;
Int32 price = (Int32)SQLCommand.ExecuteScalar();
txtbox1.Text = price.ToString();
return;
}
catch
{
}
example of my database:
Item MAJOR MINOR NFF
RAD 199 250 300
MFD 300 555 66969
Aucun commentaire:
Enregistrer un commentaire