Exemple #1
0
        private bool TestServerConnection()
        {
            //try
            //{

            string SQL = "SELECT * FROM users;";

            Reader = DBConnect.Reading(SQL);
            if (Reader != null)
            {
                lblStatus.Text      = lblStatus.Text + ("Local server connection successful");
                lblStatus.ForeColor = Color.Green;
                Reader.Close();
                return(true);
            }
            else
            {
                Reader.Close();
                return(false);
            }
            // }
            //catch
            //{
            //    lblStatus.Text = ("You are not able to connect to the server contact the administrator for further assistance");
            //    lblStatus.ForeColor = Color.Red;
            //    return false;
            //}
        }
Exemple #2
0
        public static bool ExistsAnd(string table, string field1, string field2, string value1, string value2)
        {
            string exists = "";
            string SQL    = "SELECT * FROM " + table + " WHERE " + field1 + "= '" + value1 + "' AND " + field2 + "= '" + value2 + "'";

            if (!Helper.Type.Contains("Lite"))
            {
                Reader = DBConnect.Reading(SQL);
                while (Reader.Read())
                {
                    exists = Reader.IsDBNull(0) ? "" : Reader.GetString(0);
                }
                Reader.Close();
                DBConnect.CloseConn();

                if (exists != "")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                try
                {
                    SQLconnect.ConnectionString = dbobject.datalocation();
                    SQLconnect.Open();
                }
                catch
                {
                }

                SQLiteCommand cmd = new SQLiteCommand();
                cmd             = SQLconnect.CreateCommand();
                cmd.CommandText = SQL;
                while (Reader.Read())
                {
                    exists = Reader.IsDBNull(0) ? "" : Reader.GetString(0);
                }
                Reader.Close();

                if (exists != "")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }