Address
-
Hi .. Everyone Im trying to a simple address lookup using winform. What im trying to do is have a text box were a user can type in their PostCode/zip code and it will do a simple database(Sql) lookup but you do not have to type in your full postcode/ zip i can b just the first few characters and it still should find the full address information .. Can any one help me with this because im stuck on this
-
Hi .. Everyone Im trying to a simple address lookup using winform. What im trying to do is have a text box were a user can type in their PostCode/zip code and it will do a simple database(Sql) lookup but you do not have to type in your full postcode/ zip i can b just the first few characters and it still should find the full address information .. Can any one help me with this because im stuck on this
-
Well did you try anything yet? Are you creating this database? Let's see some code, what do you have done so far, which part are you specifically stuck on?
using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; namespace AddressFinder { public partial class AddressSelecter : Form { private static readonly object EventClose = new object(); public event EventHandler OnClose { add { Events.AddHandler(EventClose,value); } remove { Events.RemoveHandler(EventClose,value); } } public virtual void OnCloseEvent(EventArgs e) { EventHandler handler = (EventHandler) Events[EventClose]; if(handler!=null) { handler(this, e); } } public AddressSelecter() { InitializeComponent(); } private string buildingNo; public string BuildingNo { get { return buildingNo; } set { buildingNo = value; } } private string street; public string Street { get { return street; } set { street = value; } } private string city; public string City { get { return city; } set { city = value; } } private string country; public string Country { get { return country; } set { country = value; } } public string PostCode { get { return txtPostCode.Text; } set { txtPostCode.Text = value; } } private void button1_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand(@"select b.buildingId, b.buildingname, s.streetname, c.cityname from zipcode z inner join city c on z.CityID = c.CityID inner join building b on z.zipcodeid = b.zipcodeid inner join street s on z.zipcodeid
-
using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; namespace AddressFinder { public partial class AddressSelecter : Form { private static readonly object EventClose = new object(); public event EventHandler OnClose { add { Events.AddHandler(EventClose,value); } remove { Events.RemoveHandler(EventClose,value); } } public virtual void OnCloseEvent(EventArgs e) { EventHandler handler = (EventHandler) Events[EventClose]; if(handler!=null) { handler(this, e); } } public AddressSelecter() { InitializeComponent(); } private string buildingNo; public string BuildingNo { get { return buildingNo; } set { buildingNo = value; } } private string street; public string Street { get { return street; } set { street = value; } } private string city; public string City { get { return city; } set { city = value; } } private string country; public string Country { get { return country; } set { country = value; } } public string PostCode { get { return txtPostCode.Text; } set { txtPostCode.Text = value; } } private void button1_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand(@"select b.buildingId, b.buildingname, s.streetname, c.cityname from zipcode z inner join city c on z.CityID = c.CityID inner join building b on z.zipcodeid = b.zipcodeid inner join street s on z.zipcodeid
-
Use autocomplete on your textbox and bind your postal codes as a datasource, or you can use wildcards for your sql statement albeit you will get multiple results if a search overlaps 2 or more results. I would use wildcards.
Im sorry to bother you .. but do you think that looking at my code is it very good or is no that good .. becuase i have only just started C# 2 weeks ago and i tought my self .. I dont know how to use wildcard .. if they is an example i can follow i would be happy :-)
-
Im sorry to bother you .. but do you think that looking at my code is it very good or is no that good .. becuase i have only just started C# 2 weeks ago and i tought my self .. I dont know how to use wildcard .. if they is an example i can follow i would be happy :-)
If youre using access the wildcard is * or if you are using mssql or mysql the wildcard is % For instance you have a table called names with Lesley, Leyla and mike if you do select * from names where name LIKE e% you will get results of Lesley and Leyla. You are off to a good start for 2 weeks, look up on good practices and naming conventions. Edit; its no bother, you are making an effort and thats what counts.