public semt semtGetirId(int semtId) { semt s = new semt(); try { SqlCommand com = new SqlCommand("select * from Semt where SemtId = @smtId", con); com.Parameters.AddWithValue("@smtId", semtId); com.CommandType = CommandType.Text; con.Open(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { s.SemtAd = dr["SemtAd"].ToString(); s.SemtId = Convert.ToInt32(dr["SemtId"]); s.IlceId = Convert.ToInt32(dr["IlceId"]); } dr.Close(); } catch (Exception ex) { } finally { con.Close(); } return(s); }
public List <semt> semtGetirTum() { List <semt> semtler = new List <semt>(); try { SqlCommand com = new SqlCommand("select * from Semt order by SemtAd", con); com.CommandType = CommandType.Text; con.Open(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { semt s = new semt(); s.SemtAd = dr["SemtAd"].ToString(); s.SemtId = Convert.ToInt32(dr["SemtId"]); s.IlceId = Convert.ToInt32(dr["IlceId"]); semtler.Add(s); } dr.Close(); } catch (Exception ex) { } finally { con.Close(); } return(semtler); }