i wonder how can i make a search box like this.
http://www.youtube.com/watch?v=3cJinHSSkuI&feature=related
i tried to convert the code in the description but it didn't work haha
i wonder how can i make a search box like this.
http://www.youtube.com/watch?v=3cJinHSSkuI&feature=related
i tried to convert the code in the description but it didn't work haha
Write this query on button_click event it will return every occurrence of your entered string in database
String Command="select OrderNumber, Address, City ,Zipcode from Table_name where OrderNumber like '%"+ searchTextBox.text+"%'"
You want to do an sql query which would return all the order numbers, which contains the inserted number in textBox? The order is not counting at all?
I can see you typed into a textBox 10078, and the return was 2 results: 1007851103 and 11007859.
2nd order number has 11 on the beginning - this is not what you wrote into textBox. So does it mean you return every single order number that contains at least all those numbers combination? This is strange. And it is leading no where.
If I was wrong in my last statement, you cna do it like:
private void textBox1_TextChanged(object sender, EventArgs e)
{
DataTable table = new DataTable();
//getting new results:
using (SqlConnection sqlConn = new SqlConnection("connectionString"))
{
string query = @"SELECT OrderNumber, Address, City, ZipCode FROM Customer WHERE OrderNumber = @number";
SqlCommand cmd = new SqlCommand(query,sqlConn);
cmd.Parameters.Add("@number", SqlDbType.Int).Value = textBox1.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(table);
}
//clearing and populating listView:
listView1.Items.Clear();
foreach (DataRow dr in table.Rows)
{
ListViewItem lvi = new ListViewItem(dr[0].ToString());
lvi.SubItems.Add(dr[1]);
lvi.SubItems.Add(dr[2]);
lvi.SubItems.Add(dr[3]);
listView1.Items.Add(lvi);
}
}
lvi.SubItems.Add(dr[1]);
lvi.SubItems.Add(dr[2]);
lvi.SubItems.Add(dr[3]);
got an error it says cannot convert to System.Windows.Forms.listViewItems.ListViewSubItems
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.