string str = "select * from Books"; OleDbDataAdapter da = new OleDbDataAdapter(str,con.GetConnection()); DataSet ds = new DataSet(); da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0].DefaultView;
using System;using System.Collections.Generic;using System.Text;using System.Data;using System.Windows.Forms;using System.Data.OleDb;
namespace Bookshop{ class Connection { OleDbConnection con;
public OleDbConnection GetConnection() { try { ...
Printset prt;//要显示的窗体 private void toolStripMenuItem39_Click(object sender, EventArgs e) { if (prt == null || prt.IsDisposed) { prt = new Printset(); prt.MdiParent = this;//父窗体为当前窗体 prt.Show(); } ...
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("是否退出本系统?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { e.Cancel = false; } else { e.Cancel = true...
SqlConnection con = new SqlConnection("server = .; uid = sa; pwd= sa; database = TY_Action"); con.Open(); string Temp=null; Temp+="update TY_User set UserPassword='{0}' where UserName="+"'"+name+"'";
string sql=string.Format(Temp,this.textNewPassword.Text);
SqlC...
在form的定义或构造函数里加上
this.Closing += new CancelEventHandler(Form_Closing);
这一句,然后
private void Form_Closing(object sender,System.ComponentModel.CancelEventArgs e) { DialogResult result = MessageBox.Show("确定退出本系统?未保存的数据将会丢失!","确认退出系统",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning); ...
当我们开发C#代码的时候,经常碰到一个问题,有些class提供Close(),有些class提供Dispose(),那么Dispose和Close到底有什么区别?首先,Dispose和Close基本上应该是一样的。Close是为了那些不熟悉Dispose的开发者设计的。因为基本上所有的developer都知道Close是干吗的(特别是对于那些有C++背景的developer)。但是当我们写code时候,如果要实现Close和Dispose的时候,要注意Close和Dispose的设计模式。.net的一些class只提供Close,而且派生自IDisposable,并且隐藏了Dispose...
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;
namespace WindowsApplication1{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class login : System.Windows.Forms.Form { private ...
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;
namespace AddUser{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windo...
int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,UINT nType = MB_OK );参数:lpszText: 消息正文lpszCaption:消息框标题(默认没有)nType:消息框的风格nType取值:1.消息框的风格? MB_ICONQUESTION! MB_ICONWARNINGX MB_ICONHAND or MB_ICONSTOPi MB_ICONINFORMATION2.Button Array:按钮 消息框类型[YES] [NO] MB_YESNO[YES][NO][CANCEL] MB_YES...
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;
namespace sqlconnction{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System....
改编自V星[视窗王子]应答程序,如下:
using System;class Queen{const int SIZE = 8;//皇后数public static void Main(){int[] Queen = new int [SIZE];//每行皇后的位置int y,x,i,j,d,t=0;y = 0;Queen[0] = -1;while( true ){for (x=Queen[y]+1; x<SIZE; x++){for (i=0;i<y;i++){j = Queen;d = y-i;//检查新皇后是否与以前的皇后能相互攻击if ((j==x)||(j==x-d)...
MD5 md5=new MD5CryptoServiceProvider();byte[] bt=Encoding.Default.GetBytes("待加密字符串");//将待加密字符转为 字节型数组byte[] resualt=md5.ComputeHash(bt);//将字节数组转为加密的字节数组string pwds = BitConverter.ToString(resualt).Replace("-","");//将数字转为string 型去掉内部的无关字符
using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;
namespace codeImage{ /// <summary> /// WebForm1 的摘要说明。 ///...