|
♂-穿越时空() 09:57:28
请教大家一个问题,ACCESS 默认的CODEPAGE 可以改吗?
♂-穿越时空() 09:59:41
我这里一个C#程序,连接SQL server 使用 绑定参数 没有问题, 连接ACCESS 就不行了, 目前搞不清楚ACCESS 的默认CODEPAGE
♂[石家庄]1234() 10:00:22
ACCESS用的是oledb
♂¤好孩子¤ () 10:00:25
连接字符串?
♂-穿越时空() 10:01:47
string SqlSelectCommand = "SELECT count(*) from [login_table] "
//+ " where ((username = @username) AND (password = @password))"
//+ " where ((username = '黄成') AND (password = @password))"
+ " where ((username = @username) AND (password = '12345'))"
;
//SqlSelectCommand = string.Format("select username from login_table "
// + " where ((username = '{0}') AND (password = @password))",strUserName)
// ;
cmd.CommandText = SqlSelectCommand;
OleDbParameter p1 = cmd.Parameters.Add("@password", OleDbType.VarChar, 50);
p1.Direction = ParameterDirection.Input;
p1.Value = strPassword;
OleDbParameter p2 = cmd.Parameters.Add("@username", OleDbType.VarChar, 50);
p2.Direction = ParameterDirection.Input;
♂-穿越时空() 10:01:58
不是连接问题
♂站长苏飞() 10:03:15
p1.Direction = ParameterDirection.Input;
♂站长苏飞() 10:03:22
这个不用加也
♂yipeilin() 10:04:30
♂yipeilin() 10:04:53
怎么取不到PlaceHolder
♂yipeilin() 10:04:58
的值
♂-穿越时空() 10:06:03
string SqlSelectCommand = "SELECT count(*) from [login_table] " +
" where (username = @username AND password = @password)";
cmd.CommandText = SqlSelectCommand;
SqlParameter p1 = cmd.Parameters.Add("@password", SqlDbType.NVarChar, 50);
p1.Direction = ParameterDirection.Input;
p1.Value = strPassword;
SqlParameter p2 = cmd.Parameters.Add("@username", SqlDbType.NVarChar, 50);
p2.Direction = ParameterDirection.Input;
p2.Value = strUserName;
♂yipeilin() 10:07:47
怎么取不到PlaceHolder的值
♂¤好孩子¤ () 10:08:47
cmd.Parameters.Add("@password",SqlDbType.NVarchar,50).Value=strPassword;
cmd.Parameters.Add("@username", SqlDbType.NVarChar, 50).Value=strUserName;
就行了,不用那么多
♂yipeilin() 10:09:24
怎么取不到PlaceHolder的值 跪求解答
♂-穿越时空() 10:10:46
string SqlSelectCommand = "SELECT count(*) from [login_table] "
//+ " where ((username = @username) AND (password = @password))"
//+ " where ((username = '黄成') AND (password = @password))"
+ " where ((username = @username) AND (password = '12345'))"
;
♂-穿越时空() 10:10:58
加不加都不是主要问题
♂-穿越时空() 10:11:52
上面的语句,用中间的就可以成功string SqlSelectCommand = "SELECT count(*) from [login_table] "
+ " where ((username = '黄成') AND (password = @password))"
;
♂-穿越时空() 10:12:14
所以我断定是CODEPAGE问题
♂-穿越时空() 10:13:00
用户名是中文,密码是数字, 密码动态参数就成功
♂[电工]Lucker() 10:13:06
♂-穿越时空() 10:14:20
SQL SERVER 默认的CODEPAGE 和 C# 都是UNICODE,所以 全部用动态参数都没有问题
|
|