我有一個方法:獲取錯誤的返回,SQL - 如果
private bool bla()
{
int Minbuy, ordersTillNow;
{
SqlConnection connection = new SqlConnection("Data Source=****;Initial Catalog=****;User ID=****;Password=****;Integrated Security=False;");
string commandtext = "SELECT Minbuy FROM items WHERE main = 1";
string commandtext2 = "SELECT ordersTillNow FROM items WHERE main = 1";
SqlCommand command = new SqlCommand(commandtext, connection);
SqlCommand command2 = new SqlCommand(commandtext2, connection);
connection.Open();
Minbuy = (int)command.ExecuteScalar();
ordersTillNow = (int)command2.ExecuteScalar();
if (Minbuy < ordersTillNow)
return true;
else
return false;
}
}
而且在page_負載的利用方法:
if (bla())
{
Image_V.Visible = true;
}
else
{
Image_X.Visible = true;
}
的對結果查詢中的值SQL是:
MinBuy = 5
ordersTillNow = 1
奇怪的是 - nevermind數據庫中的值是什麼(我已將值更改爲:MinBuy = 1和ordersTillNow = 8) - 它顯示image_v。 (在aspx頁面上 - 圖像可見的兩個都設置爲false)。
代碼有什麼問題?
的DESGIN表:
表名:項目
列:的itemId(INT),主(位),MinBuy(INT),ordersTillNow(INT)。
你能告訴我們表結構嗎?項目表中的主鍵是主鍵嗎? – ysrb
@ysrb:是的,我將結構添加到問題的底部。 – Oshrib