dataGridView数据绑定

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;
2007-08-21 19:28 | 阅读 1054 次 | 评论 0 条

Access数据连接

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 { ...
2007-08-11 00:03 | 阅读 1353 次 | 评论 0 条

MDI用法

Printset prt;//要显示的窗体 private void toolStripMenuItem39_Click(object sender, EventArgs e) { if (prt == null || prt.IsDisposed) { prt = new Printset(); prt.MdiParent = this;//父窗体为当前窗体 prt.Show(); } ...
2007-08-11 00:02 | 阅读 988 次 | 评论 0 条

判断是否退出窗体

private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("是否退出本系统?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { e.Cancel = false; } else { e.Cancel = true...
2007-08-11 00:01 | 阅读 1000 次 | 评论 0 条

密码修改

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...
2007-05-17 19:25 | 阅读 1138 次 | 评论 0 条

c#窗体的关闭按钮关闭整个程序

在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); ...
2007-05-16 20:06 | 阅读 3817 次 | 评论 0 条

C#中Dispose和Close的区别

当我们开发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...
2007-05-11 22:36 | 阅读 1475 次 | 评论 0 条

简单的用户登陆

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 ...
2007-05-11 19:42 | 阅读 1025 次 | 评论 0 条

添加用户

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...
2007-04-30 19:08 | 阅读 819 次 | 评论 0 条

MessageBox的完整用法

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...
2007-04-29 20:50 | 阅读 1294 次 | 评论 0 条

查看用户的账号和密码

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....
2007-04-29 19:32 | 阅读 1569 次 | 评论 0 条

八皇后问题的C#解答

改编自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)...
2007-04-17 22:44 | 阅读 751 次 | 评论 0 条

[转]C# winform 中 MD5 加密

MD5 md5=new MD5CryptoServiceProvider();byte[] bt=Encoding.Default.GetBytes("待加密字符串");//将待加密字符转为 字节型数组byte[] resualt=md5.ComputeHash(bt);//将字节数组转为加密的字节数组string pwds = BitConverter.ToString(resualt).Replace("-","");//将数字转为string 型去掉内部的无关字符
2007-04-17 22:27 | 阅读 737 次 | 评论 0 条

[转]C# 随机验证码

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 的摘要说明。 ///...
2007-04-17 22:25 | 阅读 1028 次 | 评论 0 条
最新评论