public cadde caddeGetirId(int caddeId) { cadde c = new cadde(); try { SqlCommand com = new SqlCommand("select * from Cadde where CaddeId = @cdId", con); com.Parameters.AddWithValue("@cdId", caddeId); com.CommandType = CommandType.Text; con.Open(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { c.CaddeAd = dr["CaddeAd"].ToString(); c.CaddeId = Convert.ToInt32(dr["CaddeId"]); c.SemtId = Convert.ToInt32(dr["SemtId"]); } dr.Close(); } catch (Exception ex) { } finally { con.Close(); } return(c); }
public List <cadde> caddeGetirTum() { List <cadde> caddeler = new List <cadde>(); try { SqlCommand com = new SqlCommand("select * from Cadde order by CaddeAd", con); com.CommandType = CommandType.Text; con.Open(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { cadde c = new cadde(); c.CaddeAd = dr["CaddeAd"].ToString(); c.CaddeId = Convert.ToInt32(dr["CaddeId"]); c.SemtId = Convert.ToInt32(dr["SemtId"]); caddeler.Add(c); } dr.Close(); } catch (Exception ex) { } finally { con.Close(); } return(caddeler); }