コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public static bool checkPrimaryKey(string sql)
 {
     if (String.IsNullOrEmpty(MyConnect.getString(sql)))
     {
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public static SqlDataReader getReader(string sql)
        {
            MyConnect.Connect();
            SqlCommand    cmd    = new SqlCommand(sql, con);
            SqlDataReader reader = cmd.ExecuteReader();

            return(reader);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
                }
            }
        }
コード例 #9
0
 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);
     }
 }