ExecuteScalarOnDB() публичный статический Метод

public static ExecuteScalarOnDB ( string sSQL, string s_ConnectionString ) : object
sSQL string
s_ConnectionString string
Результат object
        protected override void SavePersonalizationBlob
            (WebPartManager webPartManager, string path, string userName,
            byte[] dataBlob)
        {
            System.Data.Odbc.OdbcCommand    updateCommand    = null;
            System.Data.Odbc.OdbcConnection updateConnection = null;
            string sSQL = null;

            try
            {
                sSQL             = "SELECT COUNT(`username`) FROM `personalization` WHERE `username` = '" + userName + "' AND `path` = '" + path + "' and `applicationname` = '" + m_ApplicationName + "';";
                updateConnection = new System.Data.Odbc.OdbcConnection(System.Configuration.ConfigurationManager.ConnectionStrings[m_ConnectionStringName].ToString());
                if (int.Parse(RawDBQuery.ExecuteScalarOnDB(sSQL, System.Configuration.ConfigurationManager.ConnectionStrings[m_ConnectionStringName].ToString()).ToString()) > 0)
                {
                    sSQL          = "UPDATE `personalization` SET `personalizationblob` = ? WHERE `username` = ? AND `applicationname` = ? AND `path` = ?;";
                    updateCommand = new System.Data.Odbc.OdbcCommand(sSQL, updateConnection);
                    updateCommand.Parameters.Clear();
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("personalizationblob", dataBlob));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("username", userName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("applicationname", m_ApplicationName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("path", path));
                }
                else
                {
                    sSQL          = "INSERT INTO `personalization` (`username`,`path`,`applicationname`,`personalizationblob`) VALUES (?, ?, ?, ?);";
                    updateCommand = new System.Data.Odbc.OdbcCommand(sSQL, updateConnection);
                    updateCommand.Parameters.Clear();
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("username", userName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("path", path));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("applicationname", m_ApplicationName));
                    updateCommand.Parameters.Add(new System.Data.Odbc.OdbcParameter("personalizationblob", dataBlob));
                }
                updateConnection.Open();
                updateCommand.ExecuteNonQuery();
            }
            finally
            {
                if (updateConnection != null)
                {
                    if (updateConnection.State != System.Data.ConnectionState.Closed)
                    {
                        updateConnection.Close();
                    }
                    else
                    {
                        updateConnection.Dispose();
                    }
                }
                updateConnection = null;
                if (updateCommand != null)
                {
                    updateCommand.Dispose();
                }
                updateCommand = null;
                sSQL          = null;
            }
        }
        protected override void LoadPersonalizationBlobs
            (WebPartManager webPartManager, string path, string userName,
            ref byte[] sharedDataBlob, ref byte[] userDataBlob)
        {
            // Load shared state
            sharedDataBlob = null;
            userDataBlob   = null;
            object sharedBlobDataObject = null;
            object userBlobDataObject   = null;
            string sSQLShared           = null;
            string sSQLUser             = null;

            try
            {
                sSQLUser = "******" + Environment.NewLine +
                           "WHERE `username` = '" + userName + "' AND " + Environment.NewLine +
                           "`path` = '" + path + "' AND " + Environment.NewLine +
                           "`applicationname` = '" + m_ApplicationName + "';";
                sSQLShared = "SELECT `personalizationblob` FROM `personalization`" + Environment.NewLine +
                             "WHERE `username` IS NULL AND " + Environment.NewLine +
                             "`path` = '" + path + "' AND " + Environment.NewLine +
                             "`applicationname` = '" + m_ApplicationName + "';";
                sharedBlobDataObject = RawDBQuery.ExecuteScalarOnDB(sSQLShared, System.Configuration.ConfigurationManager.ConnectionStrings[m_ConnectionStringName].ToString());
                userBlobDataObject   = RawDBQuery.ExecuteScalarOnDB(sSQLUser, System.Configuration.ConfigurationManager.ConnectionStrings[m_ConnectionStringName].ToString());
                if (sharedBlobDataObject != null)
                {
                    sharedDataBlob =
                        (byte[])sharedBlobDataObject;
                }
                if (userBlobDataObject != null)
                {
                    userDataBlob =
                        (byte[])userBlobDataObject;
                }
            }
            catch (FileNotFoundException)
            {
                // Not an error if file doesn't exist
            }
            finally
            {
                sSQLUser   = null;
                sSQLShared = null;
            }
        }