选择查询不起作用在asp.net c#代码里面Visual Studio,我开发了一个搜索按钮。当我尝试运行代码时,它在编写代码时不会返回任何内容。我认为问题在于stat_leger
是用阿拉伯语写的。当数据是阿拉伯语,使用动态查询参数
SqlParameter[] para = new SqlParameter[4];
para[0] = new SqlParameter("@stat_leger", ddlACCcode.SelectedValue);
para[1] = new SqlParameter("@branch", DDLBranch.SelectedValue);
para[2] = new SqlParameter("@from", db.getDate(txtFrom.Text));
para[3] = new SqlParameter("@to", db.getDate(txtTo.Text));
DataTable dtreport = db.SelectCmdText("Select * from PostedVoucher join transactions on trans_code = stat_trans_code where stat_leger = @stat_leger and [email protected] and stat_date between @from and @to ORDER BY stat_date ", para);
GridView1.DataSource = dtreport;
GridView1.DataBind();
float GTotal = 0;
float GTotalcrd = 0;
float GTotaldeb = 0;
它工作时,我试图写在sql服务器内相同的选择。但与阿拉伯文我使用N
它是返回记录。
Select * from PostedVoucher join transactions on trans_code =
stat_trans_code
where stat_sub_leger = N'الصندوق' and branch= N'الفرع الرئيسي' and stat_date between '2013-12-05 00:00:00.000' AND '2013-12-05 00:00:00.000' ORDER BY stat_date ;
我试图把它写在选择但仍无法正常工作:
DataTable dtreport = db.SelectCmdText("Select * from PostedVoucher join transactions on trans_code = stat_trans_code where stat_sub_leger = N'@stat_sub_leger' and [email protected] and stat_date between @from and @to ORDER BY stat_date ", para);
检查字符集的字段或表的匹配。使用报价... – 2015-03-02 11:47:55