public static bool MyExecuteQuery(string sql, byte[] image) { MyConnect.Connect(); using (SqlCommand cmd = new SqlCommand(sql, con)) { try { if (image == null) { cmd.Parameters.Add("@image", SqlDbType.Image).Value = DBNull.Value; } else { cmd.Parameters.AddWithValue("@image", image); } cmd.ExecuteNonQuery(); } catch { return(false); } finally { MyConnect.Disconncet(); cmd.Dispose(); } return(true); } }
public static bool checkPrimaryKey(string sql) { if (String.IsNullOrEmpty(MyConnect.getString(sql))) { return(true); } return(false); }
public static SqlDataReader getReader(string sql) { MyConnect.Connect(); SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader reader = cmd.ExecuteReader(); return(reader); }
public static string MyExecuteScalar(string sql) { MyConnect.Connect(); SqlCommand cmd = new SqlCommand(sql, con); string s = cmd.ExecuteScalar().ToString(); MyConnect.Disconncet(); cmd.Dispose(); return(s); }
public static DataTable getTable(string strSelect) { DataTable table = new DataTable(); MyConnect.Connect(); SqlDataAdapter adapter = new SqlDataAdapter(strSelect, con); adapter.Fill(table); MyConnect.Disconncet(); adapter.Dispose(); return(table); }
public static bool checkUserName(string username) { if (String.IsNullOrEmpty(username)) { return(false); } string sql = "select UserName from LogIn where UserName=N'" + username + "'"; if (String.IsNullOrEmpty(MyConnect.getString(sql))) { return(false); } return(true); }
public static bool checkPassword(string username, string password) { string sql1 = "select Password from LogIn where UserName=N'" + username + "'"; string key = ReadXML.GetString("MyResource.xml", "setting/KeyCrypt"); string s = StringPassword.DecrytString(MyConnect.getString(sql1), key); if (String.IsNullOrEmpty(s)) { return(false); } if (s.Equals(password)) { return(true); } return(false); }
public static string getString(string sql) { string s = null; MyConnect.Connect(); using (SqlCommand cmd = new SqlCommand(sql, con)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { s = reader[0].ToString(); } MyConnect.Disconncet(); cmd.Dispose(); reader.Close(); return(s); } } }
public static bool MyExecuteQuery(string sql) { MyConnect.Connect(); using (SqlCommand cmd = new SqlCommand(sql, con)) { try { cmd.ExecuteNonQuery(); } catch { return(false); } finally { MyConnect.Disconncet(); cmd.Dispose(); } return(true); } }