protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=ENTERKEY001;Initial Catalog=ContactManagement;Integrated Security=True");//DataBase Connection
String NAME = TextBox4.Text;
SqlCommand getID = new SqlCommand("SELECT ID FROM UserDetailsOne WHERE NAME='" + NAME + "'", con);
con.Open();
SqlDataReader dr = getID.ExecuteReader();
if (dr.Read())
{
String ID = dr[0].ToString();
SqlCommand getBLOCK = new SqlCommand("SELECT BLOCK FROM UserDetailsTwo WHERE ID='" + ID + "'", con);
dr.Close();
SqlDataReader dr0 = getBLOCK.ExecuteReader();
if (dr0.Read())
{
String BLOCK = dr0[0].ToString();
if (BLOCK == "false")
{
SqlCommand cmd = new SqlCommand("select NAME,UserDetailsOne.ID,ADDRESS,GENDER,MOBILENO,PHOTO from UserDetailsOne left join UserDetailsTwo on UserDetailsOne.ID=UserDetailsTwo.ID where NAME like @NAME", con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
con.Close();
}
else
{
Response.Redirect("1.aspx");
}
}
}
}
答案 0 :(得分:0)
if(Convert.ToBoolean(tablename.Rows[index row][index columns])=true)
{
//do sth
}
访问表的一种方法是列索引,或者如果要查找列名,可以在[]
中写入名称“”