代码怎么写,求高手指导

解决方案 »

  1.   

    sqlconnection,sqlcommand
    实例到51aspx.com里看看
      

  2.   

    晕死 买本书看看吧
    其实昨天我打了一段代码回复你的时候 csdn提示正在升级 气死了
      

  3.   

    如果是一张表里的数据,一个实体就传进去了,如果是两张或者更多表里的数据,我弄个给你参考下,
     protected void Button1_Click(object sender, EventArgs e)
        {
            //添加订单
            Model.Orders o = new Model.Orders();
            o.O_ID = DateTime.Now.ToString().Replace("-", "").Replace("-","");
            o.O_Email = Session["email"].ToString();
            o.O_ReceiveName = TextBox2.Text;
            o.O_Phone = TextBox3.Text;
            o.O_PostalCode = TextBox5.Text;
            o.O_Address = TextBox4.Text;
            o.O_OrderDate = DateTime.Now;
            o.O_IsDeal = false;
            o.O_IsPaid = false;
            BLL.Orders.InsertOrders(o);
            //添加订单明细
            Dictionary<int, int> cart = (Dictionary<int, int>)Session["cart"];
            var OrderDetailsQuery =
                from order in cart
                let p = BLL.Product.GetAllProductByP_ID(order.Key)
                select new Model.OrderDetails { O_ID = o.O_ID, P_ID = p.P_ID, P_Name = p.P_Name, P_SalePrice = p.P_SalePrice, OD_Quantity=order.Value };
            if (BLL.OrderDetails.InsertAllArderDetails(OrderDetailsQuery))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "a", "alert('您的订单已提交,请耐心等待处理。');", true);
            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "a", "alert('提交失败!');", true);
            }
        }当然都是调用的业务逻辑层的方法,比较简单的添加查询方法