分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程
HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成
HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子
好的![]() |
yq1993311 发表于 2015-4-20 17:32 恩好的,那慢慢做吧,有问题可以在我这个论坛提问 |
站长苏飞 发表于 2015-4-20 17:27 谢谢,解决了。我先在在做毕业设计理财系统,我先在做得都快哭了 |
最好的办法是把你的[user] 这个表名改一下。 |
SqlCommand cmd = new SqlCommand("Select count(*) from [user] where 用户名='" + username.Text + "' and 密码='" + password.Text + "'", conn); |
站长苏飞 发表于 2015-4-20 17:11 好的,谢谢提醒亲。但是还是没有解决,mydata是我建的数据库,user是其中的表。这是全部代码 我建的类的代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; namespace stu { class DBconn { public static SqlConnection stucon() { return new SqlConnection("server=.;database=mydata;uid=sa;pwd=yq1993311"); } } } 登陆界面的代码: 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 stu { public partial class login : Form { public login() { InitializeComponent(); } private void bt_denglv_Click(object sender, EventArgs e) { SqlConnection conn = stu.DBconn.stucon(); conn.Open(); SqlCommand cmd = new SqlCommand("Select count(*) from user where 用户名='" + username.Text + "' and 密码='" + password.Text + "'", conn); int i = Convert.ToInt32(cmd.ExecuteScalar()); if (i > 0) { Form2 frm = new Form2(); frm.Show(); this.Hide(); } else MessageBox.Show("用户名和密码错误"); } } } |
select count(*) from mydata.user 改成 select count(*) from mydata.[user] user是关键字,建表的时候可以加个前缀什么的,比如my_user就没事了。 另外提醒一下,发帖子不要突省事,截图发代码会下跑一大半人的, 想帮你还要对着图一个一个的打代码。太麻烦了。 |