You still need to add connection property as below, also check some of the changes I made for a better errors management(top 1 in select and finally):
string command = "SELECT top 1 NFF FROM dbo.Prices WHERE Item ='MFD'
";
SqlConnection SQLCON = new SqlConnection(System.Configuration.ConfigurationManager.
ConnectionStrings["DefaultConnection"].ConnectionString);
try
{
SQLCON.Open();
SqlCommand SQLCommand = new SqlCommand();
SQLCommand.CommandType = CommandType.Text;
SQLCommand.Connection = SQLCON;
SQLCommand.CommandText = command;
Int32 price = (Int32)SQLCommand.ExecuteScalar();
return;
}
catch
{
}
finally
{
SQLCON.Close();
}
Fouad Roumieh
No comments:
Post a Comment