Advertisement
thebys

sqlvraci0

May 8th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1.         public static int getdistrictid(string okres)
  2.         {
  3.             int id;
  4.             string dname = okres;
  5.             string cstring = Properties.Settings.Default.volbydbConnectionString;
  6.             SqlConnection sqlpripojeni = new SqlConnection(cstring);
  7.             SqlCommand getrid = new SqlCommand("SELECT DistrictId FROM Districts WHERE Name= @Districtname", sqlpripojeni);
  8.             getrid.Parameters.Add(new SqlParameter("@Districtname", dname));
  9.             sqlpripojeni.Open();
  10.             id = Convert.ToInt32(getrid.ExecuteScalar());
  11.             sqlpripojeni.Close();
  12.             return id;
  13.         }
  14.  
  15. //pokazde vrati 0
  16. //pokud se dname nahradi konkretnim vyrazim funguje spravne
  17. //dname ma spatne kodovani?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement