狂砍程序 发表于 2008-5-14 20:57

存储过程返回表问题

方法
public static void  woako(DataList dls)
    {
        string conn = System.Configuration.ConfigurationManager.AppSettings["wokao"];
        SqlConnection con = new SqlConnection(conn);
        SqlCommand com = new SqlCommand("wokao", con);
        try
        {
            con.Open();
            com.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(com);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dls.DataSource = ds.Tables[0];
            con.Close();
        }
存储过程
create procedure wokao --执行查询
       
        as
        select * from Blog
        return

加载
protected void Page_Load(object sender, EventArgs e)
    {
        DB.woako(this.DataList1);
        this.DataList1.DataBind();
    }

数据库有数据,问题是运行了无数据显示,帮个忙,3Q

hebingbing 发表于 2008-5-14 21:02

SqlDataAdapter da = new SqlDataAdapter(com,con);

狂砍程序 发表于 2008-5-15 20:31

SqlCommand com = new SqlCommand("wokao", con);
我的com已经连接过了啊,SqlDataAdapter不是只要在连接com就行了吗,难道还要连接一次数据库?

hebingbing 发表于 2008-5-15 20:49

奥……
对不起,我没有看清楚……
实在对不起……
呵呵……

狂砍程序 发表于 2008-5-17 02:34

没关系啊,已经解决了谢谢

页: [1]

编程论坛