[align=left]public partial class FormLogin : Form
[/align][align=left]
{
[align=left]
#region Static Fields
[align=left]
public static SqlConnection cnn;
[align=left]
public static SqlDataAdapter da;
[align=left]
public const string ConnectionString = "Data Source=LCZF;Initial Catalog=lczf;Integrated Security=True";
[align=left]
#endregion
[align=left]
[align=left]
public FormLogin()
[align=left]
{
[align=left]
InitializeComponent();
[align=left]
}
[align=left]
[/align][align=left]
[align=left]
private void buttonLogin_Click(object sender, EventArgs e)
[align=left]
{
[align=left]
string name = textBoxLoginName.Text, word = textBoxLoginPassWord.Text;
[align=left]
[/align][align=left]
cnn = new SqlConnection();
[align=left]
cnn.ConnectionString = ConnectionString;
[align=left]
cnn.Open();
[align=left]
SqlCommand cmd = cnn.CreateCommand();
[align=left]
= "SELECT UserName,PassWord FROM User";
[align=left]
SqlDataReader dr = cmd.ExecuteReader();
[align=left]
while (dr.Read())
[align=left]
{
[align=left]
if ((dr.GetValue(0).ToString()) == (name.ToString()))
[align=left]
{
[align=left]
if (dr.GetValue(1).ToString() == (word.ToString()))
[align=left]
{
[align=left]
textBoxLoginName.Text = "true";
[align=left]
}
[align=left]
}
}
运行后错误出现在: SqlDataReader dr = cmd.ExecuteReader();
错误提示: [size=3][font=宋体]在关键字 'User' 附近有语法错误。[/size][/font]
[size=3]
[/size]
[size=3][font=宋体]错误是否是出现在[size=2]public const string ConnectionString = "Data Source=LCZF;Initial Catalog=lczf;Integrated Security=True";[/size][/size][/font]
[font=宋体]还是在 = "SELECT UserName,PassWord FROM User";[/font]
[font=宋体]请各位DX指教
[/font]