1、SQL创建数据库和表
create database xuesheng
go
use xuesheng
go
create table login
(
username varchar ( 50 ) ,
pwd varchar ( 20 ) ,
)
go
create table information
(
id int identity ( 1000 , 1 ) primary key ,
name varchar ( 20 ) not null ,
sex char ( 2 ) ,
jiguan varchar ( 50 ) ,
shijian varchar ( 50 ) ,
minzu varchar ( 50 ) ,
idcard varchar ( 50 ) ,
addr varchar ( 50 ) ,
)
go
2、c#登陆页面简易设计 ![这里可自由设计](https://img-blog.csdnimg.cn/20191224225150324.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pfenlj,size_16,color_FFFFFF,t_70)
登陆代码
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. Data. SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public static string name1;
public Form1 ( )
{
InitializeComponent ( ) ;
}
private void button1_Click ( object sender, EventArgs e)
{
string constr = ( "Data Source=.;Initial Catalog=a;Integrated Security=True" ) ;
string username = txt_username. Text;
string pwd = txt_pwd. Text;
name1 = txt_username. Text;
SqlConnection con = new SqlConnection ( constr) ;
SqlCommand cmd = new SqlCommand ( ) ;
cmd. Connection = con;
cmd. CommandText = string . Format ( "select count (*) from b where username like '{0}'and pwd like'{1}'" , username , pwd) ;
con. Open ( ) ;
int i = Convert. ToInt32 ( cmd. ExecuteScalar ( )</