Click here to Skip to main content
16,017,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am trying to insert non English character in SQL from ASP.NET, but it is not inserting in database.
------------------------------------------------------
vc_firstname_on_credit_card is nvarchar in table also.
------------------------------------------------------
SQL
CREATE PROCEDURE [dbo].[client_billing_address_sp_update] 
(
@in_type tinyint,
@vc_firstname_on_credit_card nvarchar(50) = ''
) 
AS
IF(@in_type = 1) 
BEGIN
INSERT INTO dbo.client_billing_address (vc_firstname_on_credit_card )
                VALUES(@vc_firstname_on_credit_card)
END

-------------
Please help ?
Posted
v2
Comments
minal21 12-Dec-12 0:58am    
Hi,
Can you specify the type of input parameter you are providing(i.e non english characters)
k@ran 12-Dec-12 1:21am    
i am using hindi and chinese

1 solution

Execute your sp like this
[dbo].[client_billing_address_sp_update] 1,N'कंप्यूटर'
 
Share this answer
 
Comments
k@ran 12-Dec-12 2:07am    
cant we do this in sql server procedure
minal21 12-Dec-12 4:46am    
yes You Can...
Update your sp as
CREATE PROCEDURE [dbo].[client_billing_address_sp_update]
(
@in_type tinyint,
@vc_firstname_on_credit_card nvarchar(50) = ''
)
AS

declare @sql1 nvarchar(max)
IF(@in_type = 1)
BEGIN
set @sql1='insert into FCM_Claims(vc_firstname_on_credit_card) values(N'''+ @vc_firstname_on_credit_card + ''')';
END

try this function from your cs file

public Void InsertNonEnglish(string in_type,string vc_firstname_on_credit_card){
string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

SqlConnection con = null;
try
{
con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand("client_billing_address_sp_update", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] prm=new SqlParameter[2];

cmd.Parameters.Add("@in_type ", SqlDbType.TinyInt).Value = in_type;
cmd.Parameters.Add("@vc_firstname_on_credit_card ", SqlDbType.NVarChar, 1024).Value = vc_firstname_on_credit_card;

con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (con != null)
{
con.Close();
con.Dispose();
}
}

}
k@ran 13-Dec-12 0:09am    
thnxx
minal21 13-Dec-12 0:27am    
welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900