求教如何在visual studio中使用c#查询

现在和数据库联好了,想做一个查询功能,一个文本框,后面一个按钮,
输入编号后点击按钮,就可以输出这个编号的相关信息

SqlConnection conn = new SqlConnection(数据库的连接字符串);
conn.Open();
SqlCommand cmd = new SqlCommand("select * from 表 where 编号 = " + textBox1.Text, conn);
DataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
MessageBox(dr["你要的字段"].ToString());
}

        protected void Button1_Click(object sender, EventArgs e)
    {
                    string txcx = this.txcx.Text;
        SqlConnection conn = new SqlConnection("数据库连接");
        conn.Open();
        string sql = "select * from 表名 where 列名 like '%" + txcx + "%'";
        SqlCommand cmd = new SqlCommand(sql, conn);
        SqlDataAdapter dr = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        dr.Fill(ds, "表名");
        DataTable dt = ds.Tables["表名"];
        this.GridView1.DataSource = dt;
        this.GridView1.DataBind();
        conn.Close();
                    }