求高手帮忙检查下错误
时间:2011-12-18
来源:互联网
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace p358作业
{
class zhixing
{
//连接字符串
private const string conStr = "Data Source=LIFEI-PC;Initial Catalog=Library;Persist Security Info=True;User ID=sa;Password=sa";
#region 登录方法
public bool login(string name,string pwd,ref string mag)
{
SqlConnection conn = new SqlConnection(conStr);
try
{
string Sqlstr = "select count(*) from [User] where [loginId]='" + name + "'and [loginPwd]='" + pwd + "'";
conn.Open();
SqlCommand comm = new SqlCommand(conStr, conn);
int Result = (int)comm.ExecuteScalar();
if (Result != 1)
{
mag="登录失败!!";
return false;
}
else
{
mag="登陆成功!!";
return true;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
finally
{
conn.Close();
}
#endregion
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace p358作业
{
class Show
{
zhixing z = new zhixing();
public void showlogin()
{
Console.WriteLine("请输入用户名:");
string name = Console.ReadLine();
Console.WriteLine("请输入密码:");
string pwd = Console.ReadLine();
string mag = string.Empty;
bool log = z.login(name,pwd,ref mag);
Console.WriteLine(mag);
if (log==true)
{
showlogin();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace p358作业
{
class Program
{
static void Main(string[] args)
{
Show s = new Show();
s.showlogin();
Console.ReadLine();
}
}
}
结果提示=附近有语法错误!请帮忙找下错误!谢谢
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace p358作业
{
class zhixing
{
//连接字符串
private const string conStr = "Data Source=LIFEI-PC;Initial Catalog=Library;Persist Security Info=True;User ID=sa;Password=sa";
#region 登录方法
public bool login(string name,string pwd,ref string mag)
{
SqlConnection conn = new SqlConnection(conStr);
try
{
string Sqlstr = "select count(*) from [User] where [loginId]='" + name + "'and [loginPwd]='" + pwd + "'";
conn.Open();
SqlCommand comm = new SqlCommand(conStr, conn);
int Result = (int)comm.ExecuteScalar();
if (Result != 1)
{
mag="登录失败!!";
return false;
}
else
{
mag="登陆成功!!";
return true;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
finally
{
conn.Close();
}
#endregion
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace p358作业
{
class Show
{
zhixing z = new zhixing();
public void showlogin()
{
Console.WriteLine("请输入用户名:");
string name = Console.ReadLine();
Console.WriteLine("请输入密码:");
string pwd = Console.ReadLine();
string mag = string.Empty;
bool log = z.login(name,pwd,ref mag);
Console.WriteLine(mag);
if (log==true)
{
showlogin();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace p358作业
{
class Program
{
static void Main(string[] args)
{
Show s = new Show();
s.showlogin();
Console.ReadLine();
}
}
}
结果提示=附近有语法错误!请帮忙找下错误!谢谢
作者: javachuxuezhe_ 发布时间: 2011-12-18
string Sqlstr = "select count(*) from [User] where [loginId]='" + name + "' and [loginPwd]='" + pwd + "'";
红色部分没有加空格隔开
红色部分没有加空格隔开
作者: hefeng_aspnet 发布时间: 2011-12-18
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28