版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
.NET编程技术实验报告实验报告(2012-2013学年第二学期)课程名称:.NET编程技术学生姓名:兰天翔专业班级:10级计算机2班学院:信电学院学号:14514026学生成绩:实验一Windows应用编程[实验目的]掌握windows窗体的基本属性、事件和方法的使用。掌握常用控件的具体使用。[实验内容]完成字体设置程序。实验代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceFontSetpublicpartialclassForm1:FormstringfontFamily="宋体";floatfontSize=10.0f;FontStylefontStyle=FontStyle.Regular;publicForm1(){InitializeComponent();}privatevoidsetFont(){this.richTextBox1.Font=newFont(fontFamily,fontSize,fontStyle);}privatevoidrbSongti_CheckedChanged(objectsender,EventArgse)if(rbSongti.Checked)this.fontFamily="宋体";setFont();privatevoidrbLishu_CheckedChanged(objectsender,EventArgse)if(rbLishu.Checked)this.fontFamily="隶书";setFont();privatevoidcbBold_CheckedChanged(objectsender,EventArgse)if(cbBold.Checked){this.fontStyle=this.fontStyle|FontStyle.Bold;}elsethis.fontStyle-=FontStyle.Bold;setFont();privatevoidcbItalic_CheckedChanged(objectsender,EventArgse)if(cbItalic.Checked){this.fontStyle=this.fontStyle|FontStyle.Italic;}else{this.fontStyle-=FontStyle.Italic;}setFont();privatevoidcbUnderline_CheckedChanged(objectsender,EventArgse)if(cbUnderline.Checked){this.fontStyle=this.fontStyle|FontStyle.Underline;}else{this.fontStyle-=FontStyle.Underline;}setFont();privatevoidnumericUpDown1_ValueChanged(objectsender,EventArgse)this.fontSize=Convert.ToSingle(this.numericUpDown1.Value);setFont();ProgramusingSystem;usingSystem.Collections.Generic;usingSystem.Windows.Forms;namespaceFontSetstaticclassProgram///应用程序的主入口点。[STAThread]staticvoidMain()Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(newForm1());Forml.DesignernamespaceFontSetpartialclassForm1///必需的设计器变量。privateSystem.ComponentModel.IContainercomponents=null;///清理所有正在使用的资源。///<paramname="disposing">如果应释放托管资源,为true;否则为false。</param>protectedoverridevoidDispose(booldisposing)if(disposing&&(components!=null)){components.Dispose();}base.Dispose(disposing);#regionWindows窗体设计器生成的代码///设计器支持所需的方法-不要///使用代码编辑器修改此方法的内容。privatevoidInitializeComponent()this.groupBox1=newSystem.Windows.Forms.GroupBox();this.groupBox2=newSystem.Windows.Forms.GroupBox();this.groupBox3=newSystem.Windows.Forms.GroupBox();this.rbSongti=newSystem.Windows.Forms.RadioButton();this.rbLishu=newSystem.Windows.Forms.RadioButton();this.numericUpDown1=newSystem.Windows.Forms.NumericUpDown();this.cbBold=newSystem.Windows.Forms.CheckBox();this.cbItalic=newSystem.Windows.Forms.CheckBox();this.cbUnderline=newSystem.Windows.Forms.CheckBox();this.richTextBox1=newSystem.Windows.Forms.RichTextBox();this.groupBox1.SuspendLayout();this.groupBox2.SuspendLayout();this.groupBox3.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();this.SuspendLayout();//groupBox1this.groupBox1.Controls.Add(this.rbLishu);this.groupBox1.Controls.Add(this.rbSongti);this.groupBox1.Location=newSystem.Drawing.Point(3,206);this.groupBox1.Name="groupBox1";this.groupBox1.Size=newSystem.Drawing.Size(208,199);this.groupBox1.TabIndex=0;this.groupBox1.TabStop=false;this.groupBox1.Text="字体";//groupBox2this.groupBox2.Controls.Add(this.numericUpDown1);this.groupBox2.Location=newSystem.Drawing.Point(217,206);this.groupBox2.Name="groupBox2";this.groupBox2.Size=newSystem.Drawing.Size(201,199);this.groupBox2.TabIndex=0;this.groupBox2.TabStop=false;this.groupBox2.Text="大小";//groupBox3this.groupBox3.Controls.Add(this.cbUnderline);this.groupBox3.Controls.Add(this.cbItalic);this.groupBox3.Controls.Add(this.cbBold);this.groupBox3.Location=newSystem.Drawing.Point(424,206);this.groupBox3.Name="groupBox3";this.groupBox3.Size=newSystem.Drawing.Size(216,199);this.groupBox3.TabIndex=0;this.groupBox3.TabStop=false;this.groupBox3.Text="风格";//rbSongtithis.rbSongti.AutoSize=true;this.rbSongti.Location=newSystem.Drawing.Point(27,41);this.rbSongti.Name="rbSongti";this.rbSongti.Size=newSystem.Drawing.Size(47,16);this.rbSongti.TabIndex=0;this.rbSongti.TabStop=true;this.rbSongti.Text="宋体";this.rbSongti.UseVisualStyleBackColor=true;this.rbSongti.CheckedChanged+=newSystem.EventHandler(this.rbSongti_CheckedChanged);//rbLishuthis.rbLishu.AutoSize=true;this.rbLishu.Location=newSystem.Drawing.Point(27,81);this.rbLishu.Name="rbLishu";this.rbLishu.Size=newSystem.Drawing.Size(47,16);this.rbLishu.TabIndex=1;this.rbLishu.TabStop=true;this.rbLishu.Text="隶书";this.rbLishu.UseVisualStyleBackColor=true;this.rbLishu.CheckedChanged+=newSystem.EventHandler(this.rbLishu_CheckedChanged);//numericUpDown1this.numericUpDown1.Location=newSystem.Drawing.Point(36,52);this.numericUpDown1.Name="numericUpDown1";this.numericUpDown1.Size=newSystem.Drawing.Size(120,21);this.numericUpDown1.TabIndex=2;this.numericUpDown1.Value=newdecimal(newint[]{10,0,0,0});this.numericUpDown1.ValueChanged+=newSystem.EventHandler(this.numericUpDown1_ValueChanged);//cbBoldthis.cbBold.AutoSize=true;this.cbBold.Location=newSystem.Drawing.Point(50,41);this.cbBold.Name="cbBold";this.cbBold.Size=newSystem.Drawing.Size(48,16);this.cbBold.TabIndex=3;this.cbBold.Text="粗体";this.cbBold.UseVisualStyleBackColor=true;this.cbBold.CheckedChanged+=newSystem.EventHandler(this.cbBold_CheckedChanged);//cbItalicthis.cbItalic.AutoSize=true;this.cbItalic.Location=newSystem.Drawing.Point(50,81);this.cbItalic.Name="cbItalic";this.cbItalic.Size=newSystem.Drawing.Size(48,16);this.cbItalic.TabIndex=4;this.cbItalic.Text="斜体";this.cbItalic.UseVisualStyleBackColor=true;this.cbItalic.CheckedChanged+=newSystem.EventHandler(this.cbItalic_CheckedChanged);//cbUnderlinethis.cbUnderline.AutoSize=true;this.cbUnderline.Location=newSystem.Drawing.Point(50,121);this.cbUnderline.Name="cbUnderline";this.cbUnderline.Size=newSystem.Drawing.Size(60,16);this.cbUnderline.TabIndex=5;this.cbUnderline.Text="下划线";this.cbUnderline.UseVisualStyleBackColor=true;this.cbUnderline.CheckedChanged+=newSystem.EventHandler(this.cbUnderline_CheckedChanged);//richTextBox1this.richTextBox1.Location=newSystem.Drawing.Point(0,0);this.richTextBox1.Name="richTextBox1";this.richTextBox1.Size=newSystem.Drawing.Size(640,200);this.richTextBox1.TabIndex=1;this.richTextBox1.Text="";//Form1this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;this.ClientSize=newSystem.Drawing.Size(641,404);this.Controls.Add(this.richTextBox1);this.Controls.Add(this.groupBox3);this.Controls.Add(this.groupBox2);this.Controls.Add(this.groupBox1);this.Name="Form1";this.Text="Form1";this.groupBox1.ResumeLayout(false);this.groupBox1.PerformLayout();this.groupBox2.ResumeLayout(false);this.groupBox3.ResumeLayout(false);this.groupBox3.PerformLayout();((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();this.ResumeLayout(false);#endregionprivateSystem.Windows.Forms.GroupBoxgroupBox1;privateSystem.Windows.Forms.GroupBoxgroupBox2;privateSystem.Windows.Forms.GroupBoxgroupBox3;privateSystem.Windows.Forms.RadioButtonrbLishu;privateSystem.Windows.Forms.RadioButtonrbSongti;privateSystem.Windows.Forms.NumericUpDownnumericUpDown1;privateSystem.Windows.Forms.CheckBoxcbUnderline;privateSystem.Windows.Forms.CheckBoxcbItalic;privateSystem.Windows.Forms.CheckBoxcbBold;privateSystem.Windows.Forms.RichTextBoxrichTextBox1;实验二图形图像编程[实验目的]掌握Graphics类。掌握基本的绘图方法。掌握图像的显示和处理方法。[实验内容]完成画板应用。在窗体的空白处绘图,并将图片保存起来。实验代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceWindrawpublicpartialclassForm1:FormGraphicsdc;Bitmapbmp=newBitmap(800,800);Pointp0;Pointp1;boolisPress=false;publicForm1()InitializeComponent();dc=Graphics.FromImage(bmp);privatevoidbutton1_Click(objectsender,EventArgse)this.saveFileDialog1.Filter="BMP图片|*.bmp";if(this.saveFileDialog1.ShowDialog()==DialogResult.OK){this.bmp.Save(this.saveFileDialog1.FileName);}privatevoiddrawImage()if(isPress)dc.DrawLine(Pens.Red,p0,p1);this.pictureBox1.Image=bmp;privatevoidpictureBox1_MouseDown(objectsender,MouseEventArgse)p0=e.Location;isPress=true;privatevoidpictureBox1_MouseMove(objectsender,MouseEventArgse)p1=e.Location;drawImage();p0=p1;privatevoidpictureBox1_MouseUp(objectsender,MouseEventArgse)p1=e.Location;drawImage();isPress=false;Program:usingSystem;usingSystem.Collections.Generic;usingSystem.Windows.Forms;namespaceWindrawstaticclassProgram///应用程序的主入口点。[STAThread]staticvoidMain()Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(newForm1());Forml.designernamespaceWindrawpartialclassForm1///必需的设计器变量。privateSystem.ComponentModel.IContainercomponents=null;///清理所有正在使用的资源。///<paramname="disposing">如果应释放托管资源,为true;否则为false。</param>protectedoverridevoidDispose(booldisposing)if(disposing&&(components!=null)){components.Dispose();}base.Dispose(disposing);#regionWindows窗体设计器生成的代码///设计器支持所需的方法-不要///使用代码编辑器修改此方法的内容。privatevoidInitializeComponent()this.pictureBox1=newSystem.Windows.Forms.PictureBox();this.button1=newSystem.Windows.Forms.Button();this.saveFileDialog1=newSystem.Windows.Forms.SaveFileDialog();((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();this.SuspendLayout();//pictureBox1this.pictureBox1.BackColor=System.Drawing.Color.White;this.pictureBox1.Location=newSystem.Drawing.Point(0,0);this.pictureBox1.Name="pictureBox1";this.pictureBox1.Size=newSystem.Drawing.Size(517,361);this.pictureBox1.TabIndex=0;this.pictureBox1.TabStop=false;this.pictureBox1.MouseDown+=newSystem.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);this.pictureBox1.MouseMove+=newSystem.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);this.pictureBox1.MouseUp+=newSystem.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);//button1this.button1.Location=newSystem.Drawing.Point(0,367);this.button1.Name="button1";this.button1.Size=newSystem.Drawing.Size(75,23);this.button1.TabIndex=1;this.button1.Text="保存";this.button1.UseVisualStyleBackColor=true;this.button1.Click+=newSystem.EventHandler(this.button1_Click);//Form1this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;this.ClientSize=newSystem.Drawing.Size(517,392);this.Controls.Add(this.button1);this.Controls.Add(this.pictureBox1);this.Name="Form1";this.Text="Form1";((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();this.ResumeLayout(false);#endregionprivateSystem.Windows.Forms.PictureBoxpictureBox1;privateSystem.Windows.Forms.Buttonbutton1;privateSystem.Windows.Forms.SaveFileDialogsaveFileDialog1;实验三数据库编程[实验目的]理解ADO.NET对象模型。熟悉常用数据邦定控件的使用方法。[实验内容]完成简单学生信息系统,能够查询学生信息,增、删、改学生信息。实验代码:FormlusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceWinStuDBpublicpartialclassForm1:FormSqlHelperhelper=newSqlHelper();publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse)DataSetds;//ds=helper.SelectSqlReturnDataSet("select*fromstudent");//stringcmdText="select*fromstudentwheressex=@ssexandsno=@sno";//stringssex;//ssex="男";//stringsno;//sno="1";//SqlParameter[]pars=newSqlParameter[]//newSqlParameter("@ssex",ssex),//newSqlParameter("@sno",sno)//ds=helper.SelectSqlReturnDataSet(cmdText,pars,CommandType.Text);ds=helper.SelectSqlReturnDataSet("select*fromstudent",null,CommandType.Text);this.dataGridView1.DataSource=ds.Tables[0];privatevoiddataGridView1_CellClick(objectsender,DataGridViewCellEventArgse)//this.dataGridView1.CurrentRow.Selected=true;bindData();privatevoidbtAdd_Click(objectsender,EventArgse)stringsql="insertintostudent(sno,sname,ssex)values(@sno,@sname,@ssex)";SqlParameter[]pars=newSqlParameter[]newSqlParameter("@sno",tbSno.Text),newSqlParameter("@sname",tbSname.Text),newSqlParameter("@ssex",tbSsex.Text)intcount=helper.ExecuteSQLReturnInt(sql,pars,CommandType.Text);if(count>0)this.dataGridView1.DataSource=helper.SelectSqlReturnDataSet("select*fromstudent").Tables[0];MessageBox.Show("添加成功");privatevoiddataGridView1_CellDoubleClick(objectsender,DataGridViewCellEventArgse)if(MessageBox.Show("是否删除","删除确认",MessageBoxButtons.OKCancel)==DialogResult.OK)stringsno=this.dataGridView1.CurrentRow.Cells["sno"].Value.ToString();stringcmdText="deletefromstudentwheresno=@sno";SqlParameter[]pars=newSqlParameter[]{newSqlParameter("@sno",sno)};intcount=helper.ExecuteSQLReturnInt(cmdText,pars,CommandType.Text);if(count>0)this.dataGridView1.DataSource=helper.SelectSqlReturnDataSet("select*fromstudent").Tables[0];MessageBox.Show("删除成功");privatevoidbindData()this.tbSno.Text=this.dataGridView1.CurrentRow.Cells["sno"].Value.ToString();this.tbSname.Text=this.dataGridView1.CurrentRow.Cells["sname"].Value.ToString();this.tbSsex.Text=this.dataGridView1.CurrentRow.Cells["ssex"].Value.ToString();privatevoidbtUpdate_Click(objectsender,EventArgse)stringsno=this.dataGridView1.CurrentRow.Cells["sno"].Value.ToString();stringcmdText="updatestudentsetsname=@sname,ssex=@ssexwheresno=@sno";SqlParameter[]pars=newSqlParameter[]newSqlParameter("@sno",sno),newSqlParameter("@sname",this.tbSname.Text),newSqlParameter("@ssex",this.tbSsex.Text)intcount=helper.ExecuteSQLReturnInt(cmdText,pars,CommandType.Text);if(count>0)this.dataGridView1.DataSource=helper.SelectSqlReturnDataSet("select*fromstudent").Tables[0];MessageBox.Show("更新成功");Forml.DesignernamespaceWinStuDBpartialclassForm1///必需的设计器变量。privateSystem.ComponentModel.IContainercomponents=null;///清理所有正在使用的资源。///<paramname="disposing">如果应释放托管资源,为true;否则为false。</param>protectedoverridevoidDispose(booldisposing)if(disposing&&(components!=null)){components.Dispose();}base.Dispose(disposing);#regionWindows窗体设计器生成的代码///设计器支持所需的方法-不要///使用代码编辑器修改此方法的内容。privatevoidInitializeComponent()this.dataGridView1=newSystem.Windows.Forms.DataGridView();this.groupBox1=newSystem.Windows.Forms.GroupBox();this.label1=newSystem.Windows.Forms.Label();this.tbSno=newSystem.Windows.Forms.TextBox();this.姓名=newSystem.Windows.Forms.Label();this.tbSname=newSystem.Windows.Forms.TextBox();this.label2=newSystem.Windows.Forms.Label();this.tbSsex=newSystem.Windows.Forms.TextBox();this.btAdd=newSystem.Windows.Forms.Button();this.btUpdate=newSystem.Windows.Forms.Button();((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();this.groupBox1.SuspendLayout();this.SuspendLayout();//dataGridView1this.dataGridView1.ColumnHeadersHeightSizeMode=System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;this.dataGridView1.Location=newSystem.Drawing.Point(0,0);this.dataGridView1.Name="dataGridView1";this.dataGridView1.RowTemplate.Height=23;this.dataGridView1.Size=newSystem.Drawing.Size(450,180);this.dataGridView1.TabIndex=0;this.dataGridView1.CellDoubleClick+=newSystem.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);this.dataGridView1.CellClick+=newSystem.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);//groupBox1this.groupBox1.Controls.Add(this.tbSsex);this.groupBox1.Controls.Add(this.label2);this.groupBox1.Controls.Add(this.tbSname);this.groupBox1.Controls.Add(this.姓名);this.groupBox1.Controls.Add(this.tbSno);this.groupBox1.Controls.Add(this.label1);this.groupBox1.Location=newSystem.Drawing.Point(12,186);this.groupBox1.Name="groupBox1";this.groupBox1.Size=newSystem.Drawing.Size(213,136);this.groupBox1.TabIndex=1;this.groupBox1.TabStop=false;this.groupBox1.Text="groupBox1";//label1this.label1.AutoSize=true;this.label1.Location=newSystem.Drawing.Point(12,26);this.label1.Name="label1";this.label1.Size=newSystem.Drawing.Size(29,12);this.label1.TabIndex=0;this.label1.Text="学号";//tbSnothis.tbSno.Location=newSystem.Drawing.Point(47,20);this.tbSno.Name="tbSno";this.tbSno.Size=newSystem.Drawing.Size(100,21);this.tbSno.TabIndex=1;//姓名this.姓名.AutoSize=true;this.姓名.Location=newSystem.Drawing.Point(12,64);this.姓名.Name="姓名";this.姓名.Size=newSystem.Drawing.Size(29,12);this.姓名.TabIndex=2;this.姓名.Text="姓名";//tbSnamethis.tbSname.Location=newSystem.Drawing.Point(47,61);this.tbSname.Name="tbSname";this.tbSname.Size=newSystem.Drawing.Size(100,21);this.tbSname.TabIndex=3;//label2this.label2.AutoSize=true;this.label2.Location=newSystem.Drawing.Point(12,103);this.label2.Name="label2";this.label2.Size=newSystem.Drawing.Size(29,12);this.label2.TabIndex=4;this.label2.Text="性别";//tbSsexthis.tbSsex.Location=newSystem.Drawing.Point(47,100);this.tbSsex.Name="tbSsex";this.tbSsex.Size=newSystem.Drawing.Size(100,21);this.tbSsex.TabIndex=5;//btAddthis.btAdd.Location=newSystem.Drawing.Point(255,201);this.btAdd.Name="btAdd";this.btAdd.Size=newSystem.Drawing.Size(75,23);this.btAdd.TabIndex=2;this.btAdd.Text="添加";this.btAdd.UseVisualStyleBackColor=true;this.btAdd.Click+=newSystem.EventHandler(this.btAdd_Click);//btUpdatethis.btUpdate.Location=newSystem.Drawing.Point(255,239);this.btUpdate.Name="btUpdate";this.btUpdate.Size=newSystem.Drawing.Size(75,23);this.btUpdate.TabIndex=3;this.btUpdate.Text="修改";this.btUpdate.UseVisualStyleBackColor=true;this.btUpdate.Click+=newSystem.EventHandler(this.btUpdate_Click);//Form1this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;this.ClientSize=newSystem.Drawing.Size(451,334);this.Controls.Add(this.btUpdate);this.Controls.Add(this.btAdd);this.Controls.Add(this.groupBox1);this.Controls.Add(this.dataGridView1);this.Name="Form1";this.Text="Form1";this.Load+=newSystem.EventHandler(this.Form1_Load);((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();this.groupBox1.ResumeLayout(false);this.groupBox1.PerformLayout();this.ResumeLayout(false);#endregionprivateSystem.Windows.Forms.DataGridViewdataGridView1;privateSystem.Windows.Forms.GroupBoxgroupBox1;privateSystem.Windows.Forms.Labellabel1;privateSystem.Windows.Forms.Labellabel2;privateSystem.Windows.Forms.TextBoxtbSname;privateSystem.Windows.Forms.Label姓名;privateSystem.Windows.Forms.TextBoxtbSno;privateSystem.Windows.Forms.TextBoxtbSsex;privateSystem.Windows.Forms.ButtonbtAdd;privateSystem.Windows.Forms.ButtonbtUpdate;ProgramusingSystem;usingSystem.Collections.Generic;usingSystem.Windows.Forms;namespaceWinStuDBstaticclassProgram///应用程序的主入口点。[STAThread]staticvoidMain()Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(newForm1());SqlHelperusingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Configuration;namespaceWinStuDBpublicclassSqlHelper//privatestringmyConnString;publicstringMyConnStringget{returnSystem.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString.ToString();///根据select语句返回dataset///<returns>dataset</returns>publicDataSetSelectSqlReturnDataSet(stringsql)SqlConnectionconn=newSqlConnection(MyConnString);SqlDataAdaptersda=newSqlDataAdapter(sql,conn);DataSetds=newDataSet();sda.Fill(ds);returnds;publicDataSetSelectSqlReturnDataSet(stringsql,SqlParameter[]pars,CommandTypetype)SqlConnectionconn=newSqlConnection(MyConnString);SqlDataAdaptersda=newSqlDataAdapter(sql,conn);if(pars!=null&&pars.Length>0)foreach(SqlParameterpinpars){sda.SelectCommand.Parameters.Add(p);}sda.SelectCommand.CommandType=type;DataSetds=newDataSet();sda.Fill(ds);returnds;publicintExecuteSQLReturnInt(stringsql,SqlParameter[]pars,CommandTypetype)SqlConnectionconn=newSqlConnection(MyConnString);trySqlCommandcmd=newSqlCommand(sql,conn);if(conn.State==ConnectionState.Broken||conn.State==ConnectionState.Closed){conn.Open();}if(pars!=null&&pars.Length>0)foreach(SqlParameterpinpars){cmd.Parameters.Add(p);}cmd.CommandType=CommandType.Text;intcount=cmd.ExecuteNonQuery();returncount;catch(Exceptionex){return0;}finally{conn.Close();}//publicSqlDataReaderSelectSqlReturnDatareader(stringsql,SqlParameter[]pars,CommandTypetype)//SqlConnectionconn=newSqlConnection(MyConnString);//SqlCommandcmd=newSqlCommand(sql,conn);//if(pars!=null&&pars.Length>0)//foreach(SqlParameterpinpars)//
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年08月浙江浙江泰隆商业银行财务统计岗社会招考(814)笔试历年参考题库附带答案详解
- 2025至2031年中国鱼味香精行业投资前景及策略咨询研究报告
- 2024年08月江苏2024年北京银行南京分行校园招考笔试历年参考题库附带答案详解
- 2025至2031年中国线成形弹簧行业投资前景及策略咨询研究报告
- 2024年切纸机换刀开关项目可行性研究报告
- 2024至2030年鳄梨提取液项目投资价值分析报告
- 2024至2030年闪光灯铝电解电容器项目投资价值分析报告
- 2024至2030年中国镀锌单轴承单轮数据监测研究报告
- 2024至2030年中国尼龙粉数据监测研究报告
- 2024年08月广东2024届华夏银行广州分行校园招考笔试历年参考题库附带答案详解
- 妊娠期高血糖诊治指南
- 2024压铸机安全技术规范
- 绵阳小升初数学试题-(绵中英才学校)
- 数据中心数据中心建设项目电气工程设计方案
- 广东省深圳市2022年中考英语真题(含答案)
- 四川省泸州市(2024年-2025年小学四年级语文)统编版期末考试(上学期)试卷及答案
- 新版《铁道概论》考试复习试题库(含答案)
- 4 地表流水的力量 (教学设计)-2023-2024学年 六年级下册科学人教版
- 临床弥漫性特发性骨肥厚症(DISH)影像表现
- 【会议系统的设计与实现7300字(论文)】
- 中国慢性冠脉综合征患者诊断及管理指南2024版解读
评论
0/150
提交评论