SQL Server - Fetch gujarati data from Database using Like Statment

Asked By Pritesh on 19-Apr-11 06:56 AM
I have one table thats store gujarati data. how can I fetch gujarati data from database using Like statment.
1 colume First name="હિરેન"  how to fetch this using select statment using store procedure.? ples give me ans fast
Nikhil Mahajan replied to Pritesh on 19-Apr-11 07:19 AM
hi..

First... if you have stored gujrati data to sql server....
then to read you must have gujrati fonts insatlled on that system

if you have installed then just check the below query.. it will get data from database using gujrati lang...


    con.Open();
            SqlCommand cmd = new SqlCommand("select * table where name like @name+'%' ", con);
            cmd.Parameters.AddWithValue("@name", SqlDbType.NVarChar).Value = txt_name.Text;    //Texbox name
            GridView1.DataSource = cmd.ExecuteReader();
            GridView1.DataBind();
            con.Close();

you just have to make the datatype Nvarchar then it will display the data as it is stored in sql server.....

it will definaltly solve your problem.......
dipa ahuja replied to Pritesh on 19-Apr-11 07:50 AM
Stored Procedure:

ALTER PROCEDURE dbo.StoredProcedure1
  (
	@ename nvarchar
 
  )
	
AS
	/* SET NOCOUNT ON */
	select from emp where  ename like ''+ @ename + '%';
 
	RETURN

.CS Code:
protected void Button1_Click(object sender, EventArgs e)
{
  string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
 
  SqlConnection con = new SqlConnection(conn);
  con.Open();
  SqlCommand comm = new SqlCommand("StoredProcedure1", con);
  comm.CommandType = CommandType.StoredProcedure;
  comm.Parameters.AddWithValue("@ename", TextBox1.Text.ToString());
 
  SqlDataAdapter da = new SqlDataAdapter(comm);
 
  DataTable dt = new DataTable();
  da.Fill(dt);
  con.Close();
 
  GridView1.DataSource = dt;
  GridView1.DataBind();
}

Hope this will help you!