求解为什么插入餐品信息失败

问题描述

html代码:<tableborder="0"cellpadding="0"cellspacing="0"style="background-color:#edf6ff;font-size:9pt;height:309px;width:736px;"><tr><tdalign="center"style="height:24px;"colspan="2"><asp:LabelID="Label1"runat="server"Text="餐品新增"SkinID="font_XXLarge"></asp:Label></td></tr><tr><tdalign="left"class="style6">请选择餐品类型:<asp:DropDownListID="DropDownList_goodsType"runat="server"Width="74px"><asp:ListItemValue="1">菜肴</asp:ListItem><asp:ListItemValue="2">汤水</asp:ListItem><asp:ListItemValue="3">点心</asp:ListItem><asp:ListItemValue="4">酒水</asp:ListItem><asp:ListItemValue="5">水果</asp:ListItem></asp:DropDownList></td><tdalign="left"class="style1">餐品名称:<asp:TextBoxID="txt_goodsname"runat="server"></asp:TextBox></td></tr><tr><tdalign="left"class="style6"><asp:LabelID="Label4"runat="server"Text="价格:"></asp:Label><asp:TextBoxID="txt_price"runat="server"></asp:TextBox></td><tdalign="left"class="style1"><asp:LabelID="Label5"runat="server"Text="类型编号:"></asp:Label><asp:TextBoxID="txt_typeid"runat="server"></asp:TextBox></td></tr><tr><tdalign="left"class="style6"><asp:LabelID="Label6"runat="server"Text="主料:"></asp:Label><asp:TextBoxID="txt_main"runat="server"></asp:TextBox></td><tdalign="left"class="style1"><asp:LabelID="Label7"runat="server"Text="数量:"></asp:Label><asp:TextBoxID="number"runat="server"Width="115px"></asp:TextBox></td></tr><tr><tdalign="left"class="style6"><asp:LabelID="Label8"runat="server"Text="口感:"></asp:Label><asp:TextBoxID="txt_taste"runat="server"></asp:TextBox></td><tdalign="left"class="style1">&nbsp;</td></tr><tr><tdalign="left"class="style4"><asp:LabelID="Label12"runat="server"Text="图片:"></asp:Label><asp:FileUploadID="FileUpload_Image"runat="server"Height="19px"Width="216px"/></td><tdalign="left"class="style5">&nbsp;</td></tr><tr><tdalign="center"colspan="2"class="style2"><asp:ButtonID="btn_Ok"runat="server"Text="添加"OnClick="btn_Ok_Click"/></td></tr></table>cs代码:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;publicpartialclassadmin_add:System.Web.UI.Page{StringSqlStr;DBdb=newDB();DataSetDs=newDataSet();Stringfull_name;voidGoodsType_DataBind(){SqlStr="select*fromgoodsType";Ds=db.GetDataTableBySql(SqlStr);try{stringgoodstype_name;for(inti=0;i<Ds.Tables[0].Rows.Count;i++){goodstype_name=Ds.Tables[0].Rows[i][1].ToString();DropDownList_goodsType.Items.Add(goodstype_name);}}catch(Exception){Response.Write("<script>alert('没有获得数据!')</script>");}}protectedvoidPage_Load(objectsender,EventArgse){if(Page.IsPostBack==false){//Session["Username"]="admin";if(Session["Admin_UserName"]!=null){GoodsType_DataBind();}else{Response.Write("<scripe>alert('error')</script>");}}}protectedvoidbtn_Ok_Click(objectsender,EventArgse){if(Session["Admin_UserName"]!=null){try{stringpath_file=FileUpload_Image.PostedFile.FileName.ToString();stringfile_type=path_file.Substring(path_file.LastIndexOf("."));stringfile_name=DateTime.Now.Year.ToString()+DateTime.Now.Month.ToString()+DateTime.Now.Day.ToString()+DateTime.Now.Hour.ToString()+DateTime.Now.Minute.ToString()+DateTime.Now.Second.ToString();full_name=file_name+file_type;stringpath=Server.MapPath("../images\")+full_name;FileUpload_Image.SaveAs(path);}catch(Exception){Response.Write("<script>alert('上传文件失败!')</script>");}SqlStr="select*fromgoodsTypewheretypename='"+DropDownList_goodsType.Text.Trim()+"'";Ds=db.GetDataTableBySql(SqlStr);//stringtype_id=Ds.Tables[0].Rows[0][0].ToString();stringimage_path="../images\"+full_name;SqlStr="insertintogoodsInfo(goods_name,price,type_id,main_ingredients,number,taste,type_name,img)"+"values('"+this.txt_goodsname.Text+"','"+this.txt_price.Text+"','"+this.txt_typeid+"',"+"'"+this.txt_main+"','"+this.number.Text+"',"+"'"+this.txt_taste.Text+"','"+this.DropDownList_goodsType.Text+"',"+"'"+image_path+"')";//Response.Write(SqlStr);try{if(db.UpdateDataBySql(SqlStr)){Response.Write("<script>alert('餐品新增成功!')</script>");}else{Response.Write("<script>alert('餐品新增失败!')</script>");}}catch(Exception){Response.Write("<script>alert('餐品新增失败')</script>");}}else{Response.Write("<script>alert('error')</script>");}}}求大神们帮帮忙,感激万分!

解决方案

解决方案二:
贴下报错信息
解决方案三:
调试一下看看报错信息

时间: 2024-07-28 20:00:30

求解为什么插入餐品信息失败的相关文章

iteminserting-怎么终止Formview在验证信息失败的时候终止添加数据呢

问题描述 怎么终止Formview在验证信息失败的时候终止添加数据呢 如题目所示 主要就是我在Formview+sqldatasouce向数据库插入信息的时候 会验证信息 并弹出提示框 所以在Formview的ItemInserting事件中写出代码验证 可是我在插入信息的时候 点击添加,Formview会弹出提示框 但是数据库也会添加数据 这是为什么 应该怎么才能在验证错误的时候 终止信息插入呢 ... 本人菜鸟 求高手 大神指点谢谢

保存商品信息失败?有时成功有时失败,怎么回事?啊

问题描述 保存商品信息失败?有时成功有时失败,怎么回事?啊 5C public void saveGood() { boolean temp = false; try { Dto dto = paraDto; StringUtil.xprint(""param=="" + paraDto); //处理编号 if(optype.equals(""add_good"")){ String good_id = UniqueID.ge

linux网络编程libpcap获取网络接口信息失败

问题描述 linux网络编程libpcap获取网络接口信息失败 #include typedef u_int32_t in_addr_t; struct in_addr{ in_addr_t s_addr;}; void main(){ char error_content[PCAP_ERRBUF_SIZE]; struct in_addr net_ip_address; struct in_addr net_mask_address; char *net_interface; char *ne

为什么 elasticsearch 获取节点信息失败?

问题描述 为什么 elasticsearch 获取节点信息失败? 在 spring boot 项目中即成集成 elasticsearch(dao层数据与es交互使用的的是 spring-data-elasticsearch)首先安装了服务器端的 es 服务,和 head 插件,es 服务启动正常,node-1 为默认主节点,my-cluster 为集群名,如图: 在程序中,使用嵌入式node启动节点正常,方式如下: Node node = NodeBuilder.nodeBuilder().no

guid-windows GUID SetupDiGerClassDevs(...)获取USB设备信息失败

问题描述 windows GUID SetupDiGerClassDevs(...)获取USB设备信息失败 下面这段代码是为了获取本机USB设备驱动handle的,可是逐句运行的时候, SetupDiGerClassDevs返回值老是 INVALID_HANDLE_VALUE. #pragma comment(lib,"setupapi") //ERROR linkerror 1120 #include<Windows.h> #include<SetupAPI.h&g

世博园餐住信息网站开通

4月9日,从锦州市服务业委员会得知,2013中国·锦州世界园林博览会餐住信息平台电脑版和手机版网站已开通运行,网站地址为www.sojinhttp://www.aliyun.com/zixun/aggregation/29945.html">zhou.com,手机版网站网址为www.sojinzhou.com/m,并链接到"锦州旅游信息网".国内外游客可通过点击网址或搜索引擎输入关键词"世园会餐住"."锦州餐住"即可查询阅览网站信

在Excel表格中该如何插入批注备注信息

  坐办公室的朋友们经常会做一些报表,例如什么酒水报表.工资表.值班表,做的时候遇到特殊的情况,需要在表中备注一些信息,这个时候就用到插入批注了,那么在Excel表格中如何插入批注?下面小编就教大家如何插入批注. 1:我们以"2015年5月酒水进出表"为例,在桌面找到这个表格,用鼠标双击打开这个表,如下图 2:打开这个表之后,我们随便举个例子,如图箭头所指的地方,白酒领入15瓶,售出10瓶,应该余5瓶,但报表只余4瓶,原因是被员工打碎了一瓶,所以我们就要用到批注,备注原因了 3:我们需

PowerPoint2013中删除插入的批注信息

  ①打开PowerPoint2013幻灯片,看到我们打开的幻灯片有批注信息. ②单击审阅--删除按钮.准备吧批注删掉. ③选择第一项删除,如果幻灯片页数过多,可以选择下面的两项. ④删除完毕,从右侧任务窗格中可以看到已经没了批注.

获取群组信息失败

问题描述 我通过getGroupFromServer(groupId); 获取群详情 , 第一次进入程序的时候总会崩, 报的这个错误Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 23385 (Thread-60650) 这个方法我是在子线程里面运行的.真心求解 解决方案 groupId正确?看下崩溃的reason解决方案二:groupId 是对的  Fatal signal 11 (SIGSEGV) at 0x00000004