问题描述
数据库/******Object:DatabaseepetScriptDate:2007-7-414:46:37******/IFEXISTS(SELECTnameFROMmaster.dbo.sysdatabasesWHEREname=N'epet')DROPDATABASE[epet]GOCREATEDATABASE[epet]ON(NAME=N'epet_Data',FILENAME=N'd:workdatabaseMSSQLdataepet_Data.MDF',SIZE=1,FILEGROWTH=10%)LOGON(NAME=N'epet_Log',FILENAME=N'd:workdatabaseMSSQLdataepet_Log.LDF',SIZE=1,FILEGROWTH=10%)COLLATEChinese_PRC_CI_ASGOexecsp_dboptionN'epet',N'autoclose',N'false'GOexecsp_dboptionN'epet',N'bulkcopy',N'false'GOexecsp_dboptionN'epet',N'trunc.log',N'false'GOexecsp_dboptionN'epet',N'tornpagedetection',N'true'GOexecsp_dboptionN'epet',N'readonly',N'false'GOexecsp_dboptionN'epet',N'dbouse',N'false'GOexecsp_dboptionN'epet',N'single',N'false'GOexecsp_dboptionN'epet',N'autoshrink',N'false'GOexecsp_dboptionN'epet',N'ANSInulldefault',N'false'GOexecsp_dboptionN'epet',N'recursivetriggers',N'false'GOexecsp_dboptionN'epet',N'ANSInulls',N'false'GOexecsp_dboptionN'epet',N'concatnullyieldsnull',N'false'GOexecsp_dboptionN'epet',N'cursorcloseoncommit',N'false'GOexecsp_dboptionN'epet',N'defaulttolocalcursor',N'false'GOexecsp_dboptionN'epet',N'quotedidentifier',N'false'GOexecsp_dboptionN'epet',N'ANSIwarnings',N'false'GOexecsp_dboptionN'epet',N'autocreatestatistics',N'true'GOexecsp_dboptionN'epet',N'autoupdatestatistics',N'true'GOif((@@microsoftversion/power(2,24)=8)and(@@microsoftversion&0xffff>=724))execsp_dboptionN'epet',N'dbchaining',N'false'GOuse[epet]GOifexists(select*fromdbo.sysobjectswhereid=object_id(N'[dbo].[FK_PetDiary_PetInfo]')andOBJECTPROPERTY(id,N'IsForeignKey')=1)ALTERTABLE[dbo].[PetDiary]DROPCONSTRAINTFK_PetDiary_PetInfoGO/******Object:Table[dbo].[PetDiary]ScriptDate:2007-7-414:46:37******/ifexists(select*fromdbo.sysobjectswhereid=object_id(N'[dbo].[PetDiary]')andOBJECTPROPERTY(id,N'IsUserTable')=1)droptable[dbo].[PetDiary]GO/******Object:Table[dbo].[PetInfo]ScriptDate:2007-7-414:46:37******/ifexists(select*fromdbo.sysobjectswhereid=object_id(N'[dbo].[PetInfo]')andOBJECTPROPERTY(id,N'IsUserTable')=1)droptable[dbo].[PetInfo]GO/******Object:Table[dbo].[PetDiary]ScriptDate:2007-7-414:46:38******/CREATETABLE[dbo].[PetDiary]([diary_id][int]IDENTITY(1,1)NOTNULL,[diary_pet_id][int]NULL,[diary_date][datetime]NULL,[diary_title][varchar](300)COLLATEChinese_PRC_CI_ASNULL,[diary_weather][varchar](30)COLLATEChinese_PRC_CI_ASNULL,[diary_context][varchar](7000)COLLATEChinese_PRC_CI_ASNULL,[diary_is_public][bit]NULL,[diary_last_modify][datetime]NULL,[diary_author][varchar](30)COLLATEChinese_PRC_CI_ASNULL,[diary_author_email][varchar](200)COLLATEChinese_PRC_CI_ASNULL)ON[PRIMARY]GO/******Object:Table[dbo].[PetInfo]ScriptDate:2007-7-414:46:40******/CREATETABLE[dbo].[PetInfo]([pet_id][int]IDENTITY(1,1)NOTNULL,[pet_name][varchar](50)COLLATEChinese_PRC_CI_ASNOTNULL,[pet_sex][varchar](2)COLLATEChinese_PRC_CI_ASNULL,[pet_strength][int]NULL,[pet_cute][int]NULL,[pet_love][int]NULL,[pet_intro][varchar](7000)COLLATEChinese_PRC_CI_ASNULL,[pet_owner_name][varchar](30)COLLATEChinese_PRC_CI_ASNULL,[pet_owner_email][varchar](100)COLLATEChinese_PRC_CI_ASNULL,[pet_password][varchar](30)COLLATEChinese_PRC_CI_ASNULL,[pet_pic][varchar](300)COLLATEChinese_PRC_CI_ASNULL,[pet_type][int]NULL)ON[PRIMARY]GOALTERTABLE[dbo].[PetDiary]WITHNOCHECKADDPRIMARYKEYCLUSTERED([diary_id])ON[PRIMARY]GOALTERTABLE[dbo].[PetInfo]WITHNOCHECKADDCONSTRAINT[PK__PetInfo__76CBA758]PRIMARYKEYCLUSTERED([pet_id])ON[PRIMARY]GOALTERTABLE[dbo].[PetDiary]ADDCONSTRAINT[DF__petdiary__diary___300424B4]DEFAULT(null)FOR[diary_pet_id],CONSTRAINT[DF__petdiary__diary___30F848ED]DEFAULT(null)FOR[diary_date],CONSTRAINT[DF__petdiary__diary___31EC6D26]DEFAULT(null)FOR[diary_title],CONSTRAINT[DF__petdiary__diary___32E0915F]DEFAULT('晴')FOR[diary_weather],CONSTRAINT[DF__petdiary__diary___33D4B598]DEFAULT(null)FOR[diary_context],CONSTRAINT[DF__petdiary__diary___34C8D9D1]DEFAULT(null)FOR[diary_is_public],CONSTRAINT[DF__petdiary__diary___35BCFE0A]DEFAULT(null)FOR[diary_last_modify],CONSTRAINT[DF__petdiary__diary___36B12243]DEFAULT(null)FOR[diary_author],CONSTRAINT[DF__petdiary__diary___37A5467C]DEFAULT(null)FOR[diary_author_email]GOALTERTABLE[dbo].[PetInfo]ADDCONSTRAINT[DF__PetInfo__pet_sex__77BFCB91]DEFAULT('小')FOR[pet_sex],CONSTRAINT[DF__PetInfo__pet_str__78B3EFCA]DEFAULT('0')FOR[pet_strength],CONSTRAINT[DF__PetInfo__pet_cut__79A81403]DEFAULT('0')FOR[pet_cute],CONSTRAINT[DF__PetInfo__pet_lov__7A9C383C]DEFAULT('0')FOR[pet_love],CONSTRAINT[DF__PetInfo__pet_int__7B905C75]DEFAULT('我家的小宝贝,可乖啦!')FOR[pet_intro],CONSTRAINT[DF__PetInfo__pet_own__7C8480AE]DEFAULT(null)FOR[pet_owner_name],CONSTRAINT[DF__PetInfo__pet_own__7D78A4E7]DEFAULT(null)FOR[pet_owner_email],CONSTRAINT[DF__PetInfo__pet_pas__7E6CC920]DEFAULT(null)FOR[pet_password],CONSTRAINT[DF__PetInfo__pet_pic__7F60ED59]DEFAULT(null)FOR[pet_pic],CONSTRAINT[DF__PetInfo__pet_typ__00551192]DEFAULT(null)FOR[pet_type]GOALTERTABLE[dbo].[PetDiary]ADDCONSTRAINT[FK_PetDiary_PetInfo]FOREIGNKEY([diary_pet_id])REFERENCES[dbo].[PetInfo]([pet_id])NOTFORREPLICATIONGOaltertable[dbo].[PetDiary]nocheckconstraint[FK_PetDiary_PetInfo]GO------------------------------------------------------------------------<ahref="DeleteServlet?id=${item.value.foodInfo.id}"onclick="returnconfirm('确定要删除吗?');"><imgsrc="images/minical_btnClose.gif"/></a>
解决方案
解决方案二:
.net?
解决方案三:
<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>无标题文档</title><linkhref="CSS/style.css"rel="stylesheet"type="text/css"/><scripttype="text/javascript">functionshowDiv(){if(document.getElementById("demoa").style.display=="none"){document.getElementById("demoa").style.display="block";}else{document.getElementById("demoa").style.display="none";}}</script></head><bodyonLoad="showTime()"><divalign="left"style="padding-left:100px;"><imgsrc="image/logo.jpg"align="bottom"/>您好,欢迎来到小竹熊官方网上商城!</div><divstyle="position:absolute;right:100px;top:15px;"><imgsrc="image/user.jpg"align="absmiddle"/><ahref="#">我的账户</a>|<ahref="#">我的消息(0)</a>|<ahref="#">帮助中心</a>|<ahref="#">登录</a>|<ahref="#">注册</a></div><divstyle="position:absolute;right:100px;top:60px;"><ahref="#"class="myphone"onMouseOver="this.className='myphone'"onMouseMove="this.className='myphonemove'">15152882697</a></div><tableheight="28"align="center"width="90%"border="0"cellpadding="0"cellspacing="0"><trstyle="background-image:url(image/menu_bg.jpg);background-repeat:repeat-x;"><tdwidth="71%"height="26"align="center"valign="middle"><ahref="#"class="menu">首页</a>|<ahref="#"class="menu">公司简介</a>|<ahref="product.html"class="menu">商品展示</a>|<ahref="#"class="menu">站内新闻</a>|<ahref="#"class="menu">留言薄</a>|<ahref="#"class="menu">联系我们</a>|<ahref="#"class="menu">快速链接</a></td><tdwidth="3%"valign="middle"><imgsrc="image/gouwuche.jpg"align="middle"/></td><tdwidth="16%"><ahref="#"style="color:#FFFFFF"onMouseMove="this.style.color='#FFFFFF'"onMouseOver="this.style.color='#FF0000'">购物车中有0件商品,去结算</a></td><tdwidth="2%"><imgsrc="image/jiantou.jpg"/></td><tdwidth="8%"></td></tr></table><divstyle="position:absolute;left:100px;top:128px;">您当前位置:</div><divid="time"style="position:absolute;width:484px;height:37px;z-index:1;color:#996600;font-weight:800;font-size:18px;right:60px;top:126px;"></div><formaction=""name="priceForm"method="post"><divstyle="position:absolute;background-image:url(image/menu1_bg.jpg);height:34px;left:71px;width:90%;right:71px;top:160px;"><divalign="left"style="position:absolute;background-image:url(image/menu1_bg.jpg);padding-left:29px;left:0px;height:34px;top:0px;">热门搜索词:<ahref="#">四件套</a><ahref="#">地垫</a><ahref="#">腰托</a><ahref="#">靠垫</a><ahref="#">蚕丝被</a><ahref="#">枕芯</a><ahref="#">缎纹</a><ahref="#">磨毛</a><ahref="#">凉席</a>要能动态添加</div><divalign="right"style="position:absolute;background-image:url(image/menu1_bg.jpg);right:0px;height:34px;top:0px;">价格区间:<inputname="minPrice"type="text"size="10"class="outTextborder"onMouseOut="this.className='outTextborder'"onMouseOver="this.className='moveTextborder'"/>至<inputname="maxPrice"type="text"size="10"class="outTextborder"onMouseOut="this.className='outTextborder'"onMouseOver="this.className='moveTextborder'"/> <inputname="key"type="text"value="请输入关键字"class="outTextborder"onFocus="this.select()"onMouseOut="this.className='outTextborder'"onMouseOver="this.className='moveTextborder'"/> <inputname="search"type="button"value="搜索"/></div></div></form><divstyle="position:absolute;left:71px;height:545px;width:90%;right:71px;top:210px;border-style:solid;border-width:1px;border-color:#666600"><!--此div当做左右分割线--><divstyle="position:absolute;width:2px;left:35.5%;height:543px;background-color:#CCCCCC;"></div><!--最近新闻--><divstyle="padding-left:27px;width:35%;height:30px;"><tablewidth="100%"border="0"cellpadding="0"cellspacing="0"class="bluenottop"><trstyle="background-image:url(image/menu_bg.jpg);background-repeat:repeat-x;"><tdheight="30px"style="padding-left:20px;"class="commonwhite">最近新闻</td><tdalign="right"style="padding-right:15px;"><ahref="#"class="more">MORE>></a></td></tr><tr><td> <ahref="#">最近新闻111最近新闻最近新闻</a></td><tdalign="right"class="blue"onMouseOver="this.style.textDecoration='underline'"onMouseOut="this.style.textDecoration='none'">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue"onMouseOver="this.style.textDecoration='underline'"onMouseOut="this.style.textDecoration='none'">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr><tr><td> 最近新闻111</td><tdalign="right"class="blue">[发表时间]</td></tr><tr><tdcolspan="2"> </td></tr></table></div><!--甩卖天堂--><divstyle="position:absolute;padding-left:15px;width:62.5%;height:559px;left:400px;top:0px;"><tablewidth="100%"border="0"cellpadding="0"cellspacing="0"class="blueleftandright"><trstyle="background-image:url(image/menu_bg.jpg);background-repeat:repeat-x;"><tdheight="30px"style="padding-left:20px;"class="commonwhite">甩卖天堂</td><tdalign="right"style="padding-right:15px;"><ahref="#"class="more">MORE>></a></td></tr></table><divclass="blueleftandright"><tablewidth="98%"border="0"class="product"><tr><tdwidth="174"align="center"valign="middle"rowspan="8"><imgsrc="image/bei5.jpg"></td><td>商品类型:<spanclass="productlink">怡然相依</span></td></tr><tr><td>商品名称:<spanclass="productlink">全棉休闲绣花四件套</span></td></tr><tr><td>商品价格:¥<spanclass="yellow-bigbold">389.00</span></td></tr><tr><td>市场价格:¥<spanclass="line-middle">1049.00</span></td></tr><tr><td>商品描述:<spanclass="productlink">怡然相依全棉休闲绣花四件套怡然相依全棉休闲绣花四件套怡然相依全棉休闲绣花四件套怡然相依全棉休闲绣花四件套怡然相依全棉休闲绣花四件套怡然相依全棉休闲绣花四件套怡然相依全棉休闲绣花四件套</span></td></tr><tr><td>最近售出(<labelclass="userlink">89</label>)件</td></tr><tr><td>共有(<labelclass="blue"onClick="showDiv()">123</label>)条评论 <labelclass="blue"onClick="showDiv()">查看>></label></td></tr><tr><td><ahref="#"><imgsrc="image/jiarugouwuche.jpg"></a> <ahref="#"><imgsrc="image/lijigoumai.jpg"></a></td></tr></table></div><divclass="blueleftandright"style="background-image:url(image/menu1_bg.jpg);height:34px;width:100%;"></div></div>
解决方案四:
<!--买家评论--><divstyle="position:absolute;padding-left:15px;width:62.5%;height:200px;left:400px;top:320px;"><tablewidth="100%"border="0"cellpadding="0"cellspacing="0"class="blueleftandright"><trstyle="background-image:url(image/menu_bg.jpg);background-repeat:repeat-x;"><tdheight="30px"style="padding-left:20px;"class="commonwhite">买家评论(<labelonClick="showDiv()"class="white">123</label>)条</td><tdalign="right"style="padding-right:15px;"><ahref="#"class="more">MORE>></a></td></tr></table><divalign="center"id="demoa"class="blueleftandright"style="overflow:hidden;height:150px;padding-left:20px;"><divalign="center"id=demo3><tablewidth="100%"border="0"cellpadding="0"cellspacing="0"><tr><tdcolspan="2"align="center"><ahref="#"class="userlink">用户名1</a></td></tr><tr><tdcolspan="2"> <ahref="#"style="color:#666600">发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容</a></td></tr><tr><tdcolspan="2"align="right"><labelonMouseOver="this.style.textDecoration='underline'"onMouseOut="this.style.textDecoration='none'"class="blue">[发表的时间]</label></td></tr><tr><tdcolspan="2"align="center"><hrsize="1"width="100%"noshade="noshade"style="border:dashed;color:#414141;"></td></tr><tr><tdcolspan="2"align="center"><ahref="#"class="userlink">用户名2</a></td></tr><tr><tdcolspan="2"> <ahref="#"style="color:#666600">发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容发表的内容</a></td></tr><tr><tdcolspan="2"align="right"><labelonMouseOver="this.style.textDecoration='underline'"onMouseOut="this.style.textDecoration='none'"class="blue">[发表的时间]</label></td></tr><tr><tdcolspan="2"align="center"><hrsize="1"width="100%"noshade="noshade"style="border:dashed;color:#414141;"></td></tr></table></div><divid=demo4></div></div><divstyle="background-image:url(image/menu1_bg.jpg);background-repeat:repeat-x;height:34px;"class="blueleftandright"></div><script>varspeed1=60;demo4.innerHTML=demo3.innerHTML;demoa.scrollTop=demoa.scrollHeight;functionMarquee1(){if(demo3.offsetTop-demoa.scrollTop>=0){demoa.scrollTop+=demo4.offsetHeight;}else{demoa.scrollTop--;}}varMyMar1=setInterval(Marquee1,speed1);demoa.onmouseover=function(){clearInterval(MyMar1);}demoa.onmouseout=function(){MyMar1=setInterval(Marquee1,speed1);}</script></div><!--联系我们--><divstyle="position:absolute;padding-left:27px;width:35%;height:30px;top:380px;"><tablewidth="100%"border="0"cellpadding="0"cellspacing="0"class="blueleftandright"><trstyle="background-image:url(image/menu2_bg.jpg);background-repeat:repeat-x;"><tdcolspan="2"height="30px"style="padding-left:20px;"><ahref="#"class="commonwhite">联系我们</a></td></tr><tr><tdheight="30px"style="padding-left:20px;"class="lianxi">业务专线: 0513-85014145</td><tdrowspan="3"><imgsrc="image/phone.jpg"width="90"height="65"></td></tr><tr><tdheight="30px"style="padding-left:20px;"class="lianxi">售后服务: 0513-85014145</td></tr><tr><tdheight="30px"style="padding-left:20px;"class="lianxi">传 真: 0513-85014145</td></tr></table><divclass="blueleftandright"style="background-image:url(image/menu1_bg.jpg);height:34px;width:100%;"></div></div></div></body></html>----------------------------------
解决方案五:
解决方案六:
上面的地址错了
解决方案七:
namespaceMySchoolDAL{publicclassDBHelper{publicstaticstringconnString=@"server=.;uid=sa;pwd=sasa;database=myschool";publicstaticSqlDataReaderGetDataReader(stringsql){SqlConnectionconn=newSqlConnection(connString);SqlCommandcmd=newSqlCommand(sql,conn);conn.Open();returncmd.ExecuteReader(CommandBehavior.CloseConnection);}publicstaticboolExcuteSql(stringsql){SqlConnectionconn=newSqlConnection(connString);SqlCommandcmd=newSqlCommand(sql,conn);conn.Open();inti=cmd.ExecuteNonQuery();conn.Close();returni>0;}}}publicclassTeacherService{publicstaticList<Teacher>Select(){stringsql="select*fromteacher";SqlDataReaderreader=DBHelper.GetDataReader(sql);List<Teacher>Teachers=newList<Teacher>();while(reader.Read()){Teacherteacher=newTeacher();teacher.TeacherId=(int)reader["TeacherId"];teacher.LoginId=(string)reader["LoginId"];teacher.LoginPwd=(string)reader["LoginPwd"];teacher.TeacherName=(string)reader["TeacherName"];teacher.Sex=(string)reader["Sex"];teacher.UserStateId=(int)reader["UserStateId"];teacher.Birthday=(DateTime)reader["Birthday"];Teachers.Add(teacher);}reader.Close();returnTeachers;}}BLLpublicclassTeacherManager{publicstaticboolLogin(stringloginId,stringloginPwd){List<Teacher>Teachers=TeacherService.Select();Teachertea=Teachers.Find(delegate(Teachert){returnt.LoginId==loginId&&t.LoginPwd==loginPwd;});returntea==null?false:true;}publicstaticList<Teacher>GetAllTeachers(){returnTeacherService.Select();}publicstaticList<Teacher>GetTeachers(stringsex){List<Teacher>Teachers=TeacherService.Select();List<Teacher>ts=Teachers.FindAll(delegate(Teachert){returnt.Sex==sex;});returnts;}}DAL2publicclassDBHelpper{privatestaticstringconnString="DataSource=.;InitialCatalog=MySchool;UserID=sa;Pwd=sasa";publicstaticSqlDataReaderGetDataReader(stringsql){SqlConnectionconn=newSqlConnection(connString);conn.Open();SqlCommandcmd=newSqlCommand(sql,conn);returncmd.ExecuteReader(CommandBehavior.CloseConnection);}publicstaticboolExcuteSql(stringsql){SqlConnectionconn=newSqlConnection(connString);conn.Open();SqlCommandcmd=newSqlCommand(sql,conn);inti=cmd.ExecuteNonQuery();conn.Close();returni>0;}publicstaticDataTableGetTable(stringsql){SqlConnectionconn=newSqlConnection(connString);conn.Open();SqlDataAdapterdataAdapter=newSqlDataAdapter(sql,conn);DataSetds=newDataSet();dataAdapter.Fill(ds,"t");returnds.Tables["t"];}}publicstaticList<Teacher>Select(){stringsql="select*fromteacher";SqlDataReaderdr=DBHelpper.GetDataReader(sql);List<Teacher>teachers=newList<Teacher>();while(dr.Read()){Teacherteacher=newTeacher();teacher.TeacherId=(int)dr["TeacherId"];teacher.LoginId=(string)dr["LoginId"];teacher.LoginPwd=(string)dr["LoginPwd"];teacher.TeacherName=(string)dr["TeacherName"];teacher.Sex=(string)dr["Sex"];teacher.UserStateId=(int)dr["UserStateId"];teacher.Birthday=(DateTime)dr["Birthday"];teachers.Add(teacher);}dr.Close();returnteachers;}publicstaticList<Teacher>SelectByCase(stringsql){SqlDataReaderdr=DBHelpper.GetDataReader(sql);List<Teacher>teachers=newList<Teacher>();while(dr.Read()){Teacherteacher=newTeacher();teacher.TeacherId=(int)dr["TeacherId"];teacher.LoginId=(string)dr["LoginId"];teacher.LoginPwd=(string)dr["LoginPwd"];teacher.TeacherName=(string)dr["TeacherName"];teacher.Sex=(string)dr["Sex"];teacher.UserStateId=(int)dr["UserStateId"];teacher.Birthday=(DateTime)dr["Birthday"];teachers.Add(teacher);}dr.Close();returnteachers;}}publicstaticintIsClassName(stringname){intcount=0;stringsql=string.Format("select*fromClasswhereClassName='{0}'",name);SqlDataReaderdr=DBHelpper.GetDataReader(sql);if(dr.Read()){count=1;}dr.Close();returncount;}publicstaticboolInsert(ClassNewc){stringsql=string.Format("insertintoClassvalues('{0}',{1})",c.ClassName,c.GradeId);returnDBHelpper.ExcuteSql(sql);}publicstaticList<Subject>Select(){stringsql="select*fromSubject";SqlDataReaderdr=DBHelpper.GetDataReader(sql);List<Subject>subjects=newList<Subject>();while(dr.Read()){Subjectsubject=newSubject();subject.SubjectId=(int)dr["SubjectId"];subject.SubjectName=(string)dr["SubjectName"];subjects.Add(subject);}dr.Close();returnsubjects;}<%@PageTitle=""Language="C#"MasterPageFile="~/Default.Master"AutoEventWireup="true"CodeBehind="givemoney.aspx.cs"Inherits="bysj.givemoney"%><asp:ContentID="Content1"ContentPlaceHolderID="head"runat="server"></asp:Content><asp:ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"runat="server"><center><div><divid="money1"><br/>--交纳考试费用--<br/><br/></div><divid="money2"><divclass="height">姓 名: <asp:TextBoxID="txtName"CssClass="txtBox"runat="server"ReadOnly="true"></asp:TextBox></div><divclass="height">身份证号: <asp:TextBoxID="txtSid"CssClass="txtBox"runat="server"ReadOnly="true"></asp:TextBox></div><divclass="height">报考资格: <asp:TextBoxID="txtPro"CssClass="txtBox"runat="server"ReadOnly="true"></asp:TextBox></div><divclass="height">报考等级: <asp:DropDownListID="ddlGrade"onChange="change()"CssClass="listBoxGrade"runat="server"><asp:ListItem>==请选择==</asp:ListItem><asp:ListItem>初级</asp:ListItem><asp:ListItem>中级</asp:ListItem><asp:ListItem>高级</asp:ListItem></asp:DropDownList></div><divclass="height">考试费用: <asp:TextBoxID="txtMoney"CssClass="txtBox1"runat="server"ReadOnly="true"></asp:TextBox></div><divid="imgPadd"><asp:ImageButtonID="imgFinish"runat="server"ImageUrl="~/images/finish.jpg"onclick="imgFinish_Click"/></div></div></div></center></asp:Content>
解决方案八:
这。。。搞基呢?
解决方案九:
publicstaticvoidAlertAndLink(stringmessage,stringurl){Pagep=HttpContext.Current.HandlerasPage;p.ClientScript.RegisterStartupScript(p.GetType(),"wsl","<script>alert('"+message+"');location='"+url+"';</script>");}publicstaticvoidAlert(stringmessage){Pagep=HttpContext.Current.HandlerasPage;p.ClientScript.RegisterStartupScript(p.GetType(),"wsl","<script>alert('"+message+"');</script>");}publicstaticvoidLink(stringurl){Pagep=HttpContext.Current.HandlerasPage;p.ClientScript.RegisterStartupScript(p.GetType(),"wsl","<script>location='"+url+"';</script>");}
解决方案十:
恩,我感觉也是
解决方案十一:
intid=Convert.ToInt32(Request.QueryString["id"]);//intid=4955;ViewState["id"]=id;-----------------------------------------publicstringGetImg(objecto){stringurl="~/Images/BookCovers/"+o.ToString()+".jpg";if(File.Exists(Server.MapPath(url))){returnurl;}return"~/Images/default.jpg";}//绑定数据时将出版社id保存在隐藏域里protectedvoiddvBook_DataBound(objectsender,EventArgse){if(dvBook.CurrentMode==DetailsViewMode.Edit){DropDownListddlPub=dvBook.FindControl("ddlPub")asDropDownList;HiddenFieldhfPid=dvBook.FindControl("hfPid")asHiddenField;ddlPub.SelectedValue=hfPid.Value;}}//保存事件protectedvoidbtnSave_Click(objectsender,EventArgse){intid=(int)ViewState["id"];Booksbook=db.Books.FirstOrDefault(b=>b.Id==id);book.Title=((TextBox)dvBook.FindControl("txtTitle")).Text;book.Author=((TextBox)dvBook.FindControl("txtAuthor")).Text;book.PublishDate=Convert.ToDateTime(((TextBox)dvBook.FindControl("txtPublishDate")).Text);book.UnitPrice=Convert.ToDecimal(((TextBox)dvBook.FindControl("txtUnitPrice")).Text);book.ContentDescription=((FreeTextBox)dvBook.FindControl("ftbContentDescription")).Text;book.TOC=((FreeTextBox)dvBook.FindControl("ftbTOC")).Text;book.PublisherId=Convert.ToInt32(((DropDownList)dvBook.FindControl("ddlPub")).SelectedValue);FileUploadfulIsbn=dvBook.FindControl("fulIsbn")asFileUpload;if(fulIsbn.PostedFile.FileName!=""){book.ISBN=""+DateTime.Now.Year+DateTime.Now.Month+DateTime.Now.Day+DateTime.Now.Hour+DateTime.Now.Minute+DateTime.Now.Second+DateTime.Now.Millisecond;fulIsbn.PostedFile.SaveAs(Server.MapPath("~/Images/BookCovers/"+book.ISBN+".jpg"));}db.SubmitChanges();dvBook.ChangeMode(DetailsViewMode.ReadOnly);Binds();}--------------------------要绑定ControlToValitade确认密码:compate```
解决方案十二:
<asp:TemplateFieldHeaderText="图片:"SortExpression="Img"><EditItemTemplate><asp:ImageID="imgIsbn"runat="server"CssClass="imgBorder"ImageUrl='<%#GetImg(Eval("Img"))%>'Width="156px"Height="227px"/><br/><asp:FileUploadID="fulIsbn"runat="server"onchange="changeImg(this.value)"/><scripttype="text/javascript">functionchangeImg(img){if(img.substring(img.lastIndexOf(".")).toLowerCase()==".jpg"){document.getElementById("ContentPlaceHolder1_dvStu_imgIsbn").src=img;}else{alert("只支持jpg格式!");}}</script></EditItemTemplate><InsertItemTemplate><asp:TextBoxID="TextBox9"runat="server"Text='<%#Bind("Img")%>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:ImageID="img"runat="server"CssClass="imgBorder"ImageUrl='<%#GetImg(Eval("Img"))%>'Width="156px"Height="227px"/></ItemTemplate><HeaderStyleHorizontalAlign="Right"/><ItemStyleHorizontalAlign="Left"/></asp:TemplateField><?xmlversion="1.0"encoding="utf-8"?><configuration><appSettings><addkey="dbType"value="sql"/></appSettings><connectionStrings><addname="sql"connectionString="DataSource=.;InitialCatalog=HotelManage;UserID=sa;Pwd=sasa"/><addname="access"connectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=Hotel.mdb"/></connectionStrings></configuration>privatestaticstringconnString=ConfigurationManager.ConnectionStrings["access"].ConnectionString;if(Session["student"]==null){PageHelpper.AlertAndLink("您还未登录,请先登录!","index.aspx");}else{if(!IsPostBack){Binds();}}<?xmlversion="1.0"encoding="utf-8"?><siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"><siteMapNodeurl="~Default.aspx"title="第三波"description=""><siteMapNodeurl="BookList.aspx"title="图书列表页"description=""/><siteMapNodeurl="Search.aspx"title="搜索页"description=""/><siteMapNodeurl=""title="订单查询"description=""/><siteMapNodeurl="ShoppingCart.aspx"title="购物车"description=""/><siteMapNodeurl="~BookDetail.aspx"title="图书详细页"description=""/><siteMapNodeId=""url=""title="会员后台"description=""><siteMapNodeurl="~Register.aspx"title="用户注册"description=""/><siteMapNodeurl="~Login.aspx"title="用户登录"description=""/><siteMapNodeurl="~UserModify.aspx"title="修改个人信息"description=""/><siteMapNodeurl=""title="退出登录"description=""/></siteMapNode><siteMapNodeId=""url="~AdminDefault.aspx"title="管理员后台"description=""><siteMapNodeurl="UserList.aspx"title="用户管理"description=""><siteMapNodeurl="~AdminUserList.aspx"title="管理用户"description=""/><siteMapNodeurl="~AdminUserStateManage.aspx"title="状态管理"description=""/><siteMapNodeurl="~AdminUserEdit.aspx"title="修改用户资料"description=""/></siteMapNode><siteMapNodeurl=""title="图书管理"description=""><siteMapNodeurl="~AdminCategoryManage.aspx"title="添加图书分类"description=""/><siteMapNodeurl="~AdminBookCategory.aspx"title="为书籍分类"description=""/><siteMapNodeurl="~AdminBookDetail.aspx"title="图书详细信息"description=""/><siteMapNodeurl="~AdminBookList.aspx"title="图书列表页"description=""/><siteMapNodeurl="~AdminBookEdit.aspx"title="图书编辑页"description=""/></siteMapNode><siteMapNodeurl=""title="订单管理"description=""><siteMapNodeurl="~AdminOrderList.aspx"title="审核订单"description=""/></siteMapNode><siteMapNodeurl="~MembershipLoginOut.aspx"title="退出"description="管理员退出"></siteMapNode></siteMapNode></siteMapNode></siteMap>
解决方案十三:
privatestaticstringconnString="DataSource=.;InitialCatalog=ss;PersistSecurityInfo=True;UserID=sa;Password=sasa";publicstaticSqlDataReaderGetDataReader(stringsql){SqlConnectionconn=newSqlConnection(connString);conn.Open();SqlCommandcmd=newSqlCommand(sql,conn);returncmd.ExecuteReader(CommandBehavior.CloseConnection);}publicstaticboolExcuteSql(stringsql){SqlConnectionconn=newSqlConnection(connString);conn.Open();SqlCommandcmd=newSqlCommand(sql,conn);inti=cmd.ExecuteNonQuery();conn.Close();returni>0;}publicstaticboolInsert(Productpp){stringsql=string.Format("insertintoProductvalues('{0}','{1}')",pp.Name,pp.Image);if(ExcuteSql(sql)){returntrue;}returnfalse;}//publicstaticbyte[]ByteArrayToStr(stringstr)//{//System.Text.ASCIIEncodingencoding=newSystem.Text.ASCIIEncoding();//returnencoding.GetBytes(str);//}publicstaticList<Product>Select(){stringsql="select*fromProduct";SqlDataReaderreader=GetDataReader(sql);List<Product>products=newList<Product>();while(reader.Read()){Productppp=newProduct();ppp.Name=reader["Name"].ToString();ppp.Image=(byte[])(reader["Picture"]);products.Add(ppp);}reader.Close();returnproducts;}///<summary>///cun///</summary>///<paramname="imagePath"></param>///<returns></returns>publicstaticbyte[]GetPictureDataByPath(stringimagePath){FileStreamfs=newFileStream(imagePath,FileMode.Open);byte[]data=newbyte[fs.Length];fs.Read(data,0,data.Length);fs.Close();returndata;}///<summary>///cun///</summary>///<paramname="imgPhoto"></param>///<returns></returns>publicstaticbyte[]GetPictureDataByimg(System.Drawing.ImageimgPhoto){//将Image转换成流数据,并保存为byte[]MemoryStreammstream=newMemoryStream();imgPhoto.Save(mstream,System.Drawing.Imaging.ImageFormat.Bmp);byte[]byData=newByte[mstream.Length];mstream.Position=0;mstream.Read(byData,0,byData.Length);mstream.Close();returnbyData;}///<summary>///qu///</summary>///<paramname="streamByte"></param>///<returns></returns>publicstaticSystem.Drawing.ImageReturnPhoto(byte[]streamByte){System.IO.MemoryStreamms=newSystem.IO.MemoryStream(streamByte);System.Drawing.Imageimg=System.Drawing.Image.FromStream(ms);returnimg;}publicstaticvoidWritePhoto(byte[]streamByte){//Response.ContentType的默认值为默认值为“text/html”System.Web.HttpContext.Current.Response.ContentType="image/JPEG";//图片输出的类型有:image/GIFimage/JPEGSystem.Web.HttpContext.Current.Response.BinaryWrite(streamByte);}yemian-------------------------------------protectedvoidPage_Load(objectsender,EventArgse){//Binds();GetImg();}privatevoidGetImg(){List<Product>pps=ProductManager.Select();foreach(Productpinpps){Response.Write("<Script>alert('"+p.Name+"')</Script>");//ProductManager.WritePhoto(p.Image);}}privatevoidBinds(){Productp=newProduct();p.Name="222";p.Image=ProductManager.GetPictureDataByPath("20111022161856125.jpg");if(ProductManager.Insert(p)){Response.Write("<ScriptLanguage='JavaScript'>alert('success')</Script>");}else{Response.Write("<ScriptLanguage='JavaScript'>alert('false')</Script>");}}