retrive the data from database using like function

Posted by Nanduvenkat under ASP.NET on 6/26/2013 | Points: 10 | Views : 642 | Status : [Member] | Replies : 2
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from [sales] where fullname like @p1 ", con);


cmd.Parameters.AddWithValue("@p1",string.Concat(TextBox1.Text,"%"));

cmd.CommandType = CommandType.Text;

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds);

GridView1.DataSource = ds.Tables[0]; ;
GridView1.DataBind();
*note[db connection=Data Source=your server name;Integrated Security=true;Initial Catalog=your database name]




Responses

Posted by: Satyapriyanayak on: 6/27/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Please elaborate it more

If this post helps you mark it as answer
Thanks

Nanduvenkat, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 6/28/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks For Post please put these article in article section of website.Forum is to ask question

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Nanduvenkat, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response