Sql Database LookUp
-
Hi All I have done a Sql database look up. I put the code on the button click event. I want it so that wen i type in something in the text box it will make sure there is text in the texbox before soearching. Becuase at the moment when i debug and click the button it will ust load every thing without men typing in it. Here is my Code //Find Button private void FindButton_Click(object sender, RoutedEventArgs e) { var cmd = new SqlCommand( @"SELECT b.EafGeobldID, b.BuildingName FROM EafGeoZip z inner join EafGeoBld b on z.EafGeoZipID = b.EafGeoZipID WHERE ZIPCode LIKE '%" + tbPostCode.Text + "%'"); var reader = Read(cmd); if (!reader.HasRows) return; while (reader.Read()) { var item = new ItemObject { Key = string.Format("{0}", reader.GetString(1)), ValueOfKey = reader.GetInt64(0).ToString() }; cbBuilding.Items.Add(item); } } //TextBox public void tbPostCode_TextChanged(object sender, TextChangedEventArgs e) { } What do i have to do to accomplish this.. Thank You in advance
-
Hi All I have done a Sql database look up. I put the code on the button click event. I want it so that wen i type in something in the text box it will make sure there is text in the texbox before soearching. Becuase at the moment when i debug and click the button it will ust load every thing without men typing in it. Here is my Code //Find Button private void FindButton_Click(object sender, RoutedEventArgs e) { var cmd = new SqlCommand( @"SELECT b.EafGeobldID, b.BuildingName FROM EafGeoZip z inner join EafGeoBld b on z.EafGeoZipID = b.EafGeoZipID WHERE ZIPCode LIKE '%" + tbPostCode.Text + "%'"); var reader = Read(cmd); if (!reader.HasRows) return; while (reader.Read()) { var item = new ItemObject { Key = string.Format("{0}", reader.GetString(1)), ValueOfKey = reader.GetInt64(0).ToString() }; cbBuilding.Items.Add(item); } } //TextBox public void tbPostCode_TextChanged(object sender, TextChangedEventArgs e) { } What do i have to do to accomplish this.. Thank You in advance
-
Hi All I have done a Sql database look up. I put the code on the button click event. I want it so that wen i type in something in the text box it will make sure there is text in the texbox before soearching. Becuase at the moment when i debug and click the button it will ust load every thing without men typing in it. Here is my Code //Find Button private void FindButton_Click(object sender, RoutedEventArgs e) { var cmd = new SqlCommand( @"SELECT b.EafGeobldID, b.BuildingName FROM EafGeoZip z inner join EafGeoBld b on z.EafGeoZipID = b.EafGeoZipID WHERE ZIPCode LIKE '%" + tbPostCode.Text + "%'"); var reader = Read(cmd); if (!reader.HasRows) return; while (reader.Read()) { var item = new ItemObject { Key = string.Format("{0}", reader.GetString(1)), ValueOfKey = reader.GetInt64(0).ToString() }; cbBuilding.Items.Add(item); } } //TextBox public void tbPostCode_TextChanged(object sender, TextChangedEventArgs e) { } What do i have to do to accomplish this.. Thank You in advance
-
I dare you to type into your textbox
%';DELETE FROM EafGeoZip
read this: http://www.codeproject.com/KB/database/SqlInjectionAttacks.aspx[^]