sqlcommand的sqlstring问题

 protected void insertorderinfo(int orderid)
    {
        int orderidtemp = orderid;
        int productidtemp=0;
        int productnumbertemp = 0;
        int pricebuytemp = 0;
        int subtotaltemp = 0;
        string connstring = ConfigurationManager.ConnectionStrings["teaConnectionString"].ConnectionString;
        string sqlstring = "insert into [orderinfo](orderid,productid,productnumber,pricebuy,subtotal) values('" + orderidtemp + "','" + productidtemp + "','" + productnumbertemp + "','" + pricebuytemp + "','" + subtotaltemp + "')";
        SqlConnection Myconn = new SqlConnection(connstring);
        SqlCommand Mycomm = new SqlCommand(sqlstring, Myconn);
        DataTable dt = (DataTable)Session["shopbox"];
        try
        {
            Myconn.Open();
            foreach (DataRow dr in dt.Rows)
            {
                productidtemp =(int) dr["productid"];
                productnumbertemp = (int)dr["productnumber"];
                pricebuytemp = (int)dr["pricebuy"];
                subtotaltemp = (int)dr["subtotal"];
                Mycomm.ExecuteNonQuery();
            }
            Myconn.Close();
        }
        catch
        {
            Response.Write("出错了");
        }
       
    }
写入表后  productid productnumber pricebuy subtotal的值都为0
这个问题值得研究研究

posted on 2007-04-21 10:25  漫步人生  阅读(518)  评论(3编辑  收藏  举报