数据库表中读取信息
来源:互联网 发布:仿快手源码 编辑:程序博客网 时间:2024/05/18 01:33
//存入
string con = "Server=.;Database=UsersInfo;integrated security=SSPI";
SqlConnection mycon = new SqlConnection(con);
mycon.Open();
using (SqlCommand cmd = mycon.CreateCommand())
{
cmd.CommandText = "select * from loginInfo where Account='" + account + "'";
SqlDataReader reader = cmd.ExecuteReader();
if (!reader.Read())
{
reader.Close();
cmd.CommandText = "insert into loginInfo(Account,Password) values('" + account + "','" + passwordonce + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("注册成功");
this.Close();
}
else
{
MessageBox.Show("帐号已存在");
}
}
con.Clone();
//读取
string con;
con = "Server=.;Database=UsersInfo;integrated security=SSPI";
SqlConnection mycon = new SqlConnection(con);
mycon.Open();
using (SqlCommand cmd = mycon.CreateCommand())
{
cmd.CommandText = "select * from loginInfo where Account='" + account + "'";
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
if (reader.Read())
{
string Password = reader.GetString(reader.GetOrdinal("Password"));
if (password == Password)
{
MessageBox.Show("登陆成功");
mycon.Close();
writeInPas();
//储存当前帐号
StreamWriter sw = new StreamWriter(Application.StartupPath + "\\tmpAccount.txt", false);
sw.WriteLine(txtAccountLgn.Text);
sw.Close();
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("用户名或密码错误");
}
}
}
else
{
MessageBox.Show("用户名或密码错误");
}
}
}
- 数据库表中读取信息
- 从config文件中读取数据库信息
- 读取联系人数据库信息
- JDBC 读取数据库中的表信息和字段信息
- C# 数据库中图像信息的读取与写入
- android读取apk中已经存在的数据库信息
- 从配置文件或数据库中读取信息并缓存
- 插件62:从表中读取信息
- 读取单条数据库信息
- 读取数据库随机的信息
- 数据库存储-读取资源信息
- Ext中弹出一个Panel面板信息,面板信息从数据库中读取
- 读取Access数据库、获取Access表信息——Visual C#读取Excel和Access数据库
- 同时读取多个数据库中的表信息
- c# 如何将图片信息从数据库中读取出来放入pictureBox1中:
- jpg中读取GPS信息
- Android中读取短信信息
- 读取APK中versionCode信息
- 解决:android studio2.2.3 卡死 ,卡在Gradle:Build Running的解决办法
- 20分钟回顾基础排序与二分查找
- 如何选择合适的Linux系统和版本 day1
- OA CRM ERP傻傻分不清吗?
- Java接口知识
- 数据库表中读取信息
- 收集的一些工具类
- 一次dns缓存引发的惨案
- Java并发编程实战:并发基础构建模块
- (UVA)10082
- sqlserver启动失败
- CXF使用教程(一)——简介以及入门案例
- js设置数字每三个添加一个逗号,保留两位小数
- What kind of young people group can we cluster