首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

各位大侠,请请帮一下忙下面几段代码有异常没有,小弟在这先鞠躬了

2012-01-13 
各位大侠,请请帮一下忙下面几段代码有错误没有,小弟在这先鞠躬了! 2各位大侠,请请帮一下忙下面几段代码有

各位大侠,请请帮一下忙下面几段代码有错误没有,小弟在这先鞠躬了!

2   各位大侠,请请帮一下忙下面几段代码有错误没有,小弟在这先鞠躬了!
using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;
using   System.Data.SqlClient;

public   partial   class   backmanage_updategoods1   :   System.Web.UI.Page
{
        protected   SqlConnection   strcon   =   new   SqlConnection(System.Configuration.ConfigurationManager.AppSettings[ "conn "]);
        protected   DataSet   ds   =   new   DataSet();
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                if   (Session[ "admin "]   ==   null)
                {
                        Server.Transfer( "backlogin.aspx ");
                }
                strcon.Open();
               
             
                bind1();
                strcon.Close();
               

        }

       
        protected   void   bind1()
        {
                SqlDataAdapter   sda   =   new   SqlDataAdapter( "select   goodsname,price,memberprice,picture,introduce,latenew,youhuiprice   from   tb_goods   where   id= "   +   Request.QueryString[ "id "],   strcon);
             
                DataSet   ds   =   new   DataSet();
                sda.Fill(ds,   "tb_goods ");

                DataRow[]   rows   =   ds.Tables[0].Select();
                foreach   (DataRow   row   in   rows)
                {

                       
                       
                        txtgoodsname.Text   =   row[ "goodsname "].ToString();
                     
                     
                        txtgoodsprice.Text   =   row[ "price "].ToString();
                        txtmemberprice.Text   =   row[ "memberprice "].ToString();


                        txtgoodsintroduce.Text   =   row[ "introduce "].ToString();
                     
                        txtyouhuiprice.Text   =   row[ "youhuiprice "].ToString();
                        txtpicture.Text   =   row[ "picture "].ToString();
                        int   latenew   =   Convert.ToInt32(row[ "latenew "]);
                        if   (latenew   ==   1)
                        {
                                RadioButtonList1.SelectedIndex   =   0;
                        }
                        else   if   (latenew   ==   2)
                        {
                                RadioButtonList1.SelectedIndex   =   1;
                        }
                        else   if   (latenew   ==   3)
                        {
                                RadioButtonList1.SelectedIndex   =   2;
                        }
                }

               
               
        }

       
        protected   void   Button3_Click(object   sender,   EventArgs   e)
        {
                string   filePath   =   " ",   fileExtName   =   " ",   mFileName,   mPath;
                System.Text.StringBuilder   strMsg   =   new   System.Text.StringBuilder( "上传文件信息; <hr   color=red> ");
                if   ( " "   !=   fileup.PostedFile.FileName)
                {
                        filePath   =   fileup.PostedFile.FileName;
                        fileExtName   =   filePath.Substring(filePath.LastIndexOf( ". ")   +   1);
                        try
                        {


                                mPath   =   Server.MapPath( "../goodsimages/ ");
                                mFileName   =   filePath.Substring(filePath.LastIndexOf( "\\ ")   +   1);
                                fileup.PostedFile.SaveAs(mPath   +   mFileName);
                                Label11.Text   =   "上传成功! ";
                        }
                        catch   (Exception   err)
                        {
                                Response.Write(err.ToString());
                                Label11.Text   =   "上传失败! ";
                        }
                }
        }
        protected   void   Button2_Click(object   sender,   EventArgs   e)
        {

        }
     


        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
               
                int   mes   =   Convert.ToInt32(Request   .QueryString   [ "id "]);
             
               
                string   goodsname   =   txtgoodsname.Text.ToString();
                string   introduce   =   txtgoodsintroduce.Text.ToString();
                double   price   =   Convert.ToDouble(txtgoodsprice.Text);
                double   memberprice   =   Convert.ToDouble(txtmemberprice.Text);
                string   picture   =   "~/goodsimages/ "   +   txtpicture.Text.ToString();
             
             
               
             
                int   latenew;
                if   (RadioButtonList1.SelectedIndex   ==   0)
                {
                        latenew   =   1;
                }
                else   if   (RadioButtonList1.SelectedIndex   ==   1)


                {
                        latenew   =   2;
                }
                else   if   (RadioButtonList1.SelectedIndex   ==   2)
                {
                        latenew   =   3;
                }
                else
                {
                        latenew   =   0;
                }
                strcon.Open();
                string   str   =   "update   tb_goods   set   goodsname= ' "   +   goodsname     +   " ',introduce= ' "   +   introduce     +   " ',price= ' "   +   price     +   " ',memberprice= ' "   +   memberprice     +   " ',picture= ' "   +   picture         + " ',youhuiprice= ' "+txtyouhuiprice   .Text     + " ',latenew= ' "+latenew     +   " '   where   id= "   +   mes;
                SqlCommand   comm   =   new   SqlCommand(str,   strcon);
                try
                {
                        comm.ExecuteNonQuery();
                        Label10.Text   =   "   更新成功! ";
                }
                catch
                {
                        Label10.Text   =   "更新失败! ";
                }
                finally
                {
                        strcon.Close();
                }
        }


        protected   void   Button3_Click1(object   sender,   EventArgs   e)
        {
                string   filePath   =   " ",   fileExtName   =   " ",   mFileName,   mPath;
                System.Text.StringBuilder   strMsg   =   new   System.Text.StringBuilder( "上传文件信息; <hr   color=red> ");
                if   ( " "   !=   fileup.PostedFile.FileName)


                {
                        filePath   =   fileup.PostedFile.FileName;
                        fileExtName   =   filePath.Substring(filePath.LastIndexOf( ". ")   +   1);
                        try
                        {
                                mPath   =   Server.MapPath( "../goodsimages/ ");
                                mFileName   =   filePath.Substring(filePath.LastIndexOf( "\\ ")   +   1);
                                fileup.PostedFile.SaveAs(mPath   +   mFileName);
                                Label11.Text   =   "上传成功! ";
                        }
                        catch   (Exception   err)
                        {
                                Response.Write(err.ToString());
                                Label11.Text   =   "上传失败! ";
                        }
                }
        }
}


[解决办法]
先打印一下看SQL语句错误没
如果没有的话。在打个断点一步一步找~~

热点排行