Search This Blog

Monday, March 18, 2013

How can insert HINDI TEXT and multilingual in SQL -2008


In SQL
In SQL create a table with required data entry. And since you want to add Hindi in a column the data type should be NVARCHAR. The columns TestName are NVARCHAR data type.

In aspx page :
In the aspx page, draw a textbox and button control. Then write the following code for saving the data to a SQL Database.Write this code for the button's Click event:

Insert into hindi_Test(TestName) values(N'आइए जानते हैं कंगारुओं को कब-कब मिली करारी हार')

INSERT INTO table1 VALUES (N’your multilingual value here’)



In aspx page for SQL Stored Procedures:
 public int INS_TestData(string TestName)
        {
            dbSqlCommand = new SqlCommand();
            dbSqlCommand.Connection = dbSqlconnection;
            if (dbSqlconnection.State == ConnectionState.Closed)
                dbSqlconnection.Open();
            dbSqlCommand.CommandType = CommandType.StoredProcedure;
            dbSqlCommand.CommandText = "TestHIndiData";
            dbSqlCommand.Parameters.Add("@TestName", SqlDbType.NVarChar).Value = TestName;
            System.Data.SqlClient.SqlParameter pRowsAffected = new SqlParameter("@RowsAffected", System.Data.SqlDbType.Int);
            pRowsAffected.Direction = System.Data.ParameterDirection.Output;
            dbSqlCommand.Parameters.Add(pRowsAffected);
            try
            {
                dbSqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                return -1;
            }
            return Convert.ToInt32(pRowsAffected.Value);
        }

SQL Stored Procedures for insert hindi text in table sql 2008:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[TestHIndiData]
@TestName as nvarchar(50),
@RowsAffected int output
AS
BEGIN
INSERT INTO  dbo.hindi_Test(TestName) VALUES (@TestName)
Set @RowsAffected =@@identity
 END

No comments :