Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET1.0
hi,
 
string q1 = "select * from register where  areaofspecific like '%@area%'";
       using (SqlCommand cmd = new SqlCommand(q1, conn))
       {
           cmd.Parameters.AddWithValue("@area", TextBox4.Text);
           SqlDataAdapter adp = new SqlDataAdapter(cmd);
           adp.Fill(ds);
       }
       GridView1.DataSource = ds;
       GridView1.DataBind();
 

by using this now also i didn't get the result
 
thank u
Posted 31-Mar-11 2:12am
Edited 31-Mar-11 2:42am
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

All of the solutions are correct. But you may need to add %% on query param.
try here:
string q1 = "select * from register where  areaofspecific like @area";
cmd.Parameters.AddWithValue("@the", "%"+textBox4.Text+"%");
Not Here:
string q1 = "select * from register where  areaofspecific like '%@area%'";
 
Finally I'll say to do this:
type %myarea% inside your textbox4 and code:
string q1 = "select * from register where  areaofspecific like @area";
cmd.Parameters.AddWithValue("@the",textBox4.Text);
Because user will decide, will he give % or not inside his query.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Its an example.
try this
 
string value = TextBox1.text;
Cmd = new SqlCommand("DELETE FROM Table WHERE CountryMasterId = @ID", Con);
 Cmd.Parameters.AddWithValue("@ID", value );
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

DataSet ds = new DataSet();
string q1 = "select * from register where  areaofspecific like '@area'";
using(SqlCommand cmd = new SqlCommand(q1, conn))
{
   cmd.Parameters.AddWithValue("@area", TextBox4.Text);
   SqlDataAdapter adp = new SqlDataAdapter(cmd);
   adp.Fill(ds);
}
GridView1.DataSource = ds;
GridView1.DataBind();
  Permalink  

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

  Print Answers RSS
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Mika Wendelius 185
3 _Amy 170
4 CPallini 170


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 31 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100