我正在用C#創建一個桌面應用程序。我正在創建一個登錄表單。我有一個名爲MyTable
的表,其中列username
和password
。C#SQL Server Compact數據庫登錄
我想驗證用戶,所以我想我想知道從SQL查詢影響的行數。但每次通過執行ExecuteNonQuery()
方法得到-1
。
我的代碼:
string Username = username.Text;
string Password = password.Text;
SqlCeCommand commandSelect = new SqlCeCommand("SELECT * FROM MyTable WHERE [email protected] AND [email protected]", connection);
commandSelect.Parameters.AddWithValue("@username", Username);
commandSelect.Parameters.AddWithValue("@password", Password);
int rows = commandSelect.ExecuteNonQuery();
MessageBox.Show(rows.ToString());
在此先感謝。
謝謝。你是一個拯救生命的人。 再次感謝。 –