阿拉伯文字母的存储过程 [英] Stored procedure for arabic letters

查看:121
本文介绍了阿拉伯文字母的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码更新我的数据回合我得到??????在数据库中我写阿拉伯垃圾应该怎么办



i use this code to update my data bout i get ?????? in the database when i write arabic litter what should i do for that

create procedure [dbo].[Updateproject]
@ProjectID int,
@Title nchar(10) ,
@Description text ,
@DueBy datetime ,
@Status nvarchar(50)
as
update dbo.uni_project set Status=@Status,Title=@Title,Description=@Description,DueBy=@DueBy where projectID = @ProjectID
return 0
GO





ii在我的代码中使用此代码表格





i i use this code in my form

string str = ConfigurationManager.ConnectionStrings["my"].ConnectionString;
                using (SqlConnection sqlcon = new SqlConnection(str))
                {
                    using (SqlCommand cmd = new SqlCommand("Createproject", sqlcon))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("Title", txtTitle.Text);
                        cmd.Parameters.AddWithValue("Description", txtData.Text);
                        cmd.Parameters.AddWithValue("DueBy", cbDate.Text);
                        cmd.Parameters.AddWithValue("username", txtusername.Text);
                        
                        sqlcon.Open();
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("reminder set for" + cbDate.Text);
                    }
                }





我的尝试:





What I have tried:

update dbo.uni_project set Status=@Status,Title=N+@Title,Description=N+@Description,DueBy=@DueBy where projectID = @ProjectID



回合我没有工作


bout i didn't work

推荐答案

正如理查德已经提到的那样'如果问题在描述字段中,则可能使用错误的代码页。

最好的解决方案是使用ntext而不是文本。



如果问题出现在标题或状态字段中,则解决方案是永远不要使用AddWithValue。使用cmd.Parameters.Add()并正确指定类型。

阅读:我们可以停止使用AddWithValue()吗? [ ^ ]
As Richard already mentioned you're probably using the wrong codepage if the problem is within the description field.
Best solution for that is to use ntext instead of text.

If the problem is within the Title or Status fields, then the solution is to never use AddWithValue. Use cmd.Parameters.Add() and specify the type properly.
Read this: Can we stop using AddWithValue() already?[^]


这篇关于阿拉伯文字母的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆