资源简介
简单 适合初学者
数据库连接部分
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=chaoshi;Integrated Security=True");
con.Open();
String sql = "select * from [User]";
SqlCommand comm = new SqlCommand(sql, con);
SqlDataReader read = comm.ExecuteReader();
代码片段和文件信息
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 ;
using System.Data.SqlClient ;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void panel_OK_Paint(object sender PaintEventArgs e)
{
}
private void panel_Cancel_Paint(object sender PaintEventArgs e)
{
}
private void button1_Click(object sender EventArgs e)
{
if (textBox_Name.Text == ““ || textBox_Pass.Text == ““)
{
MessageBox.Show(“请将登录信息填写完整。“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
}
else
{
string name = textBox_Name.Text;
string pass = textBox_Pass.Text;
SqlConnection con = new SqlConnection(“Data Source=.;Initial Catalog=chaoshi;Integrated Security=True“);
con.Open();
String sql = “select * from [User]“;
SqlCommand comm = new SqlCommand(sql con);
SqlDataReader read = comm.ExecuteReader();
while (read.Read())
{
int n = 0;
if ((read[0].ToString().Trim() == name) && (read[1].ToString().Trim() == pass))//Trim()函数是将字符串开头和结尾的空格去除
{
//DialogResult = DialogResult.OK;
//this.Close();
main frm2 = new main();
frm2.ShowDialog();
n = 1;
break;
}
if(n==0)
MessageBox.Show(“对不起,您的用户名/密码不正确,请重新输入“);
}
}
}
private void button2_Click(object sender EventArgs e)
{
this.Close();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 22016 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
文件 30208 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
文件 11600 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
文件 490 2010-03-17 22:39 cdenglu\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
文件 2261 2011-06-15 10:00 cdenglu\WindowsFormsApplication1\Form1.cs
文件 6666 2011-06-15 09:54 cdenglu\WindowsFormsApplication1\Form1.Designer.cs
文件 21453 2011-06-15 09:54 cdenglu\WindowsFormsApplication1\Form1.resx
文件 372 2011-06-15 09:43 cdenglu\WindowsFormsApplication1\main.cs
文件 1182 2011-06-15 09:43 cdenglu\WindowsFormsApplication1\main.Designer.cs
文件 2152 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6365 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 492 2011-06-15 09:54 cdenglu\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.read.1.tlog
文件 1552 2011-06-15 09:54 cdenglu\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog
文件 1231 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
文件 22016 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe
文件 10721 2011-06-15 09:54 cdenglu\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources
文件 30208 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb
文件 180 2011-06-15 09:44 cdenglu\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources
文件 505 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\Program.cs
文件 1404 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\Properties\AssemblyInfo.cs
文件 2898 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\Properties\Resources.Designer.cs
文件 5612 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\Properties\Resources.resx
文件 1109 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\Properties\Settings.Designer.cs
文件 249 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\Properties\Settings.settings
文件 3891 2011-06-15 09:44 cdenglu\WindowsFormsApplication1\WindowsFormsApplication1.csproj
文件 914 2011-06-15 09:37 cdenglu\WindowsFormsApplication1.sln
..A..H. 20480 2011-06-15 10:00 cdenglu\WindowsFormsApplication1.suo
目录 0 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\obj\x86\Debug\TempPE
目录 0 2011-06-15 09:58 cdenglu\WindowsFormsApplication1\obj\x86\Debug
目录 0 2011-06-15 09:37 cdenglu\WindowsFormsApplication1\bin\Debug
............此处省略9个文件信息
相关资源
- C#非接触IC卡M1卡读写调试源代码(适
- C#设置IP地址启用禁用适配器
- C# System Hooks
- WPF 自定义窗口风格,带TOOLBAR
- 自来水收费管理系统c# 源代码
- WPFC#.net 跨线程更新UI 线程测试 解决界
- c#写的简单嗅探器(Socket)
- 在c#中ole方式加入excel
- 时间序列预测
- C# WinFrom 挂机锁屏功能实现()
-
C#的Winform多语言实现xm
l文件升级版 - C#的Winform多语言实现resx文件
- SQL Server数据库操作类(C#)
- vs2008 c#.net web二维码生成系统
- (c#)使用SHGetFileInfo获取文件或文件
- C#+使用word模板+批量打印例子192182
- C#导出数据到EXCEL方法谈附和超级无敌
- C#+AE根据点坐标生成shp文件
- seafile私有云的api的C#客户端实现
- c#窗体嵌入应用程序
- 游戏账户管理系统
- 利用C#读取DEM数据,求坡度
- C#实现十六进制AES的加解密字节数组工
- wpf全套基础视频+进阶视频
- C#从txt读取数据并保存在数组
- C#将json格式转换成DataTable
- C#实现DES加解密完整类源码
- C#开发资源库
- C#开发实例大全(基础卷/1.69G/光盘)
- c# 熵权法计算权重和算综合得分
评论
共有 条评论