0
我的C#代碼以下部分SQL LAST()函數
cmd = new SqlCommand("SELECT TOP 1 * FROM "+label7.Text+" ORDER BY searches DESC ", con);
var columnSize = cmd.ExecuteScalar();
int plithos = int.Parse(string.Format("{0}", columnSize));
哪裏con
是我的連接字符串。我想要做的就是把plithos
列searches
的最後一個值。 searches
列有超過17條記錄,但由於某種原因,plithos
獲得列搜索的第九條記錄,並且該代碼部分不假定記錄最後一條記錄的值?我正在構建的應用程序是Visual Studio中的表單應用程序。請幫助我,這是如此令人沮喪
這裏是列searches
Searches| 1 2 3 4 5 6 7 8 9-> value of plithos . . . 19
你獲取使用多列'select *'仍然調用'ExecuteScalar()',期望返回一個值。嘗試'從...中選擇前1個搜索' –
發佈表格內容。 –
@PaulAbbott我已經嘗試過,但仍然一樣。 –