再给你个LINQ +SQL2005的写法吧,界面有textBox1,textBox2,button1 控件using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Text.RegularExpressions; using System.Web.Security;//加密 // private void button1_Click(object sender, EventArgs e) { if ((Regex.IsMatch(textBox1.Text.Trim(), @"^\w+$") == false) || (Regex.IsMatch(textBox2.Text.Trim(), @"^\w+$") == false)) { MessageBox.Show("用户密码不能使用标点符号或空格", "请注意,出错啦:)"); return; }
DataClasses1DataContext dc = new DataClasses1DataContext(); var query = from a in dc.worker where a.userr == textBox1.Text.Trim() select a; if (query.Count() <= 0) { MessageBox.Show(" 没有此用户 ", "请注意,出错啦:)"); return; } if (FormsAuthentication.HashPasswordForStoringInConfigFile(textBox2.Text.Trim(), "SHA1") == Class1.mess2)//密码保存时有SHA加密的,所以要把输入的密码加密后和数据库的密码比较 {
ado.net操作
到51aspx.com里看看
Stream ms;
byte[] picbyte;
OpenFileDialog ofdSelectPic = new OpenFileDialog();
if (ofdSelectPic.ShowDialog() == DialogResult.OK)
{
if ((ms = ofdSelectPic.OpenFile()) != null)
{
picbyte = new byte[ms.Length];
ms.Position = 0;
ms.Read(picbyte, 0, Convert.ToInt32(ms.Length));
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ""; sql = "Insert into Person(Photo) values(@Image)";
SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.Add("@Image", SqlDbType.VarBinary);
cmd.Parameters["@Image"].Value = picbyte; conn.Open();
cmd.ExecuteNonQuery();
conn.Close(); ms.Close();
}
} SqlConnection conn=new SqlConnection();
conn.ConnectionString="";
string strSql="";
SqlCommand cmd=new SqlCommand(strSql,conn);
conn.Open();
SqlDataReader reader=cmd.ExecuteReader();
reader.Read();
MemoryStream ms=new MemoryStream((byte[])reader["Photo"]);
Image image=Image.FromStream(ms,true);
reader.Close();
conn.Close();
picturebox1.Image=image;
FileStream mystream=new FileStream("D:\\A.jpg",FileMode.Open,FileAccess.Read);
long len=mystream.Length;
mycmd.Parameters.Add("@image",SqlDbType.Image,(int)len,"picture");
mycmd.Parameters["@image"].Direction=System.Data.ParameterDirection.Input;
byte []box=new byte[len];
mystream.Read(box,0,(int)len);
mycmd.Parameters["@image"].Value=box;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Web.Security;//加密
//
private void button1_Click(object sender, EventArgs e)
{
if ((Regex.IsMatch(textBox1.Text.Trim(), @"^\w+$") == false) || (Regex.IsMatch(textBox2.Text.Trim(), @"^\w+$") == false))
{
MessageBox.Show("用户密码不能使用标点符号或空格", "请注意,出错啦:)");
return;
}
DataClasses1DataContext dc = new DataClasses1DataContext();
var query = from a in dc.worker
where a.userr == textBox1.Text.Trim()
select a;
if (query.Count() <= 0)
{
MessageBox.Show(" 没有此用户 ", "请注意,出错啦:)");
return;
}
if (FormsAuthentication.HashPasswordForStoringInConfigFile(textBox2.Text.Trim(), "SHA1") == Class1.mess2)//密码保存时有SHA加密的,所以要把输入的密码加密后和数据库的密码比较 {
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show(" 密码错误 ","请注意,出错啦:)");
}
}
}不会是毕业设计吧,每年这个时候老是有这种问题出来
form吧,还form,标题都写不对,哎
http://download.csdn.net/source/654648不过还是建议楼主好好学习基础知识,这样工作的时候才能轻松点,不然工作的时候遇到项目要做,而自己又不懂,但是任务又紧,恐怕你为了工作还要一边学一边做,太累。
好好学点知识,有用的