蓝派网(www.lan27.com)-精选网络资源,分享和交流! 文章首页站内搜索在线手册广告代码酷站欣赏万年历
您现在的位置: 蓝派网 >> 文章中心 >> 网络编程 >> .NET >> ASP.NET >> 正文

C# 调用存储过程并绑定Repeater

作者:佚名    文章来源:网络    更新时间:2008-10-29 19:20:42


        SqlConnection mySqlConnection = lan27_cs.GetConnection();
        SqlCommand mySqlCommand = new SqlCommand("lan27_list", mySqlConnection);
        mySqlCommand.CommandType = CommandType.StoredProcedure;

        SqlParameter lan27Par;

        //数据表名
        lan27Par = mySqlCommand.Parameters.Add("@TableName", SqlDbType.VarChar, 30);
        mySqlCommand.Parameters["@TableName"].Value = "lan27Blog";


        //数据表字段,以","号分隔
        lan27Par = mySqlCommand.Parameters.Add("@Field", SqlDbType.VarChar, 200);
        mySqlCommand.Parameters["@Field"].Value = "id,lan27";

        //查询条件,不需where"
        lan27Par = mySqlCommand.Parameters.Add("@Condition", SqlDbType.VarChar, 500);
        mySqlCommand.Parameters["@Condition"].Value = "url='www.lan27.net'";

        //显示记录数
        lan27Par = mySqlCommand.Parameters.Add("@dispnum", SqlDbType.VarChar, 150);
        mySqlCommand.Parameters["@dispnum"].Value = this.dispnum;

        //排序字段 不需要加Order By
        lan27Par = mySqlCommand.Parameters.Add("@Order", SqlDbType.VarChar, 50);
        mySqlCommand.Parameters["@Order"].Value = "lan27_id desc";

        mySqlConnection.Open();
        Repeater1.DataSource = mySqlCommand.ExecuteReader();

        Repeater1.DataBind();

        mySqlConnection.Close();


发表评论】【打印此文】【关闭窗口】【点击数:
★好玩的休闲小游戏★