这是我在数据库表中显示/搜索记录的代码。如何验证 roecord 是否存在?它正在搜索成员的 ID。如果记录不存在,我应该如何显示消息?
string connectionstring = "Server=Momal-PC\\MOMAL;Database=Project;Trusted_Connection=True;";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connectionstring;
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select * from Members where Number = '" + SearchID.Text + "'", conn);
DataTable dtStock = new DataTable();
sda.Fill(dtStock);
dataGridView1.DataSource = dtStock;
conn.Close();