阅读背景:

如何在文本框中使用带有where子句的I SqlCommand?

来源:互联网 
String strcon = ConfigurationManager.ConnectionStrings["con"].ToString();
SqlConnection con;

protected void run_save(object sender, EventArgs e)
{
    con = new SqlConnection(strcon);
    String select = txtComand.Text;
    SqlCommand cmd = new SqlCommand(select, con);
    con.Open();
    SqlDataReader dr = cmd.ExecuteReader();

    if (dr.Read())
    {
        gridview1.DataSource = dr;
        gridview1.DataBind();
        con.Close();


 <asp:TextBox runat="server" ID="txtComand" TextMode="MultiLine" Height="227px" 
            Width="352px"></asp:TextBox>

 <asp:Button runat="server" ID="idRun" OnClick="run_save" Text="RUN" />
 <asp:GridView runat="server" ID="gridview1"></asp:GridView>
String strcon = ConfigurationManager.Connection



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: