第1个回答 2007-11-03
直接给你个
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using system.data.Sqlclient;
namespace WindowsApplication2
{
private void button1_Click(object sender, EventArgs e)
{
if (user.Text.ToString() == "" || pwd.Text.ToString() == "")
{
MessageBox.Show("用户名或密码不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
sqlconnection con=new sqlConnection("server=.;database=login;uid=sa;pwd=;");
sqlcommand com=new Sqlcommand("select count(*) from login where username='"+user.text.tostring()+"' and userpwd='"+pwd.text.tostring()+"'",con):
con.open();
if com.excutescarl>0 then
Response.redirect(k.aspx)
else
massagebox("没有该记录");