public bool changeSession(string sess) { try { int i, j; string session = sess; string qrstr1;// to check whether session which is selected was previous selected or not? qrstr1 = "select session from session"; SqlCommand cmd1 = new SqlCommand(qrstr1, Gencon); SqlDataAdapter da = new SqlDataAdapter(cmd1); DataTable dt = new DataTable(); da.Fill(dt); for (i = 0; i < dt.Rows.Count; i++) for (j = 0; j < dt.Columns.Count; j++) { object o = dt.Rows[i].ItemArray[j]; //string s = dt.Rows[i].ItemArray[j].ToString(); string s = o.ToString(); if (s.Equals(session)) { return false; } } string qrstr; qrstr = "update session set session=@sess where id=@id"; SqlCommand cmd = new SqlCommand(qrstr, Gencon); cmd.Parameters.AddWithValue("@id", 1); cmd.Parameters.AddWithValue("@sess", sess); Gencon.Open(); cmd.ExecuteNonQuery(); Gencon.Close(); return true; } catch (Exception ex) { return false; } }
s
session
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)