以下是我的源代码,还有请各位大牛们帮忙看下那里有问题,
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace BackShift
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
//关闭方法
private void btnSucz_Click(object sender, EventArgs e)
{
this.Close();
}
//登录方法
private void btnLogin_Click(object sender, EventArgs e)
{
string strName = txtName.Text;
string strPwd = txtPwd.Text;
//string StrSql = "select count(*) from users where u_name=@u_name and u_pass=@u_pass";
//SqlParameter[] mySqlParameter = new SqlParameter[] {
// new SqlParameter("@u_name",strName),
// new SqlParameter("@u_pass",strPwd)
//};
//DataSet ds = SqlHelp.ReturnDataSet(StrSql, mySqlParameter, CommandType.Text);
DataSet ds = SqlHelp.ReturnDataSet("select count(*) from users where u_name='" + strName + "' and u_pass='" + strPwd + "' ");
//DataSet ds =SqlHelp ReturnDataSet("select count(*) from users where u_name='" + strName + "' and u_pass='" + strPwd + "' ", null, CommandType.Text);
string strSign = ds.Tables[0].Rows[0][0].ToString();
if (strSign == "1")
{
FormIn FI = new FormIn();
FI.Show();
txtPwd.Text = "";
this.Hide();
}
else
{
}
}
}
public class SqlHelp
{
/// <summary>
/// 执行查询语句
/// </summary>
/// <param name="strSql">查询语句</param>
/// <returns></returns>
public static DataSet ReturnDataSet(string strSql)
{
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=ceshi;Integrated Security=True");
try
{
conn.Open();