当前位置: 首页>>代码示例>>C#>>正文


C# dataAccess.TestDBConnection方法代码示例

本文整理汇总了C#中dataAccess.TestDBConnection方法的典型用法代码示例。如果您正苦于以下问题:C# dataAccess.TestDBConnection方法的具体用法?C# dataAccess.TestDBConnection怎么用?C# dataAccess.TestDBConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dataAccess的用法示例。


在下文中一共展示了dataAccess.TestDBConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveAccount

        public static string SaveAccount(string sMode, string sAccountID, string sAccountName, string sAccountNumber, string sProvider, 
			string sLoginID, string sLoginPassword, string sLoginPasswordConfirm, string sIsDefault, string sAutoManageSecurity)
        {
            // for logging
            string sOriginalName = "";

            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = "";
            string sErr = "";

            //if we are editing get the original values
            if (sMode == "edit")
            {
            }

            try
            {
                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                // update the user fields.
                if (sMode == "edit")
                {
                    sSql = "select account_name from cloud_account " +
                           "where account_id = '" + sAccountID + "'";
                    if (!dc.sqlGetSingleString(ref sOriginalName, sSql, ref sErr))
                        throw new Exception("Error getting original account name:" + sErr);

                    // only update the passwword if it has changed
                    string sNewPassword = "";
                    if (sLoginPassword != "($%#[email protected]!&")
                    {
                        sNewPassword = ", login_password = '" + dc.EnCrypt(sLoginPassword) + "'";
                    }

                    sSql = "update cloud_account set" +
                        " account_name = '" + sAccountName + "'," +
                        " account_number = '" + sAccountNumber + "'," +
                        " provider = '" + sProvider + "'," +
                        " is_default = '" + sIsDefault + "'," +
                        " auto_manage_security = '" + sAutoManageSecurity + "'," +
                        " login_id = '" + sLoginID + "'" +
                        sNewPassword +
                        " where account_id = '" + sAccountID + "'";

                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception("Error updating account: " + sErr);

                    ui.WriteObjectChangeLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, sOriginalName, sAccountName);}
                else
                {
                    //now, for some reason we were having issues with the initial startup of apache
                    //not able to perform the very first database hit.
                    //this line serves as an inital db hit, but we aren't trapping it or showing the error
                    dc.TestDBConnection(ref sErr);

                    //if there are no rows yet, make this one the default even if the box isn't checked.
                    if (sIsDefault == "0")
                    {
                        int iExists = -1;

                        sSql = "select count(*) as cnt from cloud_account";
                        if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
                        {
                            System.Threading.Thread.Sleep(300);
                            if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
                            {
                                System.Threading.Thread.Sleep(300);
                                if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
                                    throw new Exception("Unable to count Cloud Accounts: " + sErr);
                            }
                        }

                        if (iExists == 0)
                            sIsDefault = "1";
                    }

                    sAccountID = ui.NewGUID();
                    sSql = "insert into cloud_account (account_id, account_name, account_number, provider, is_default, login_id, login_password, auto_manage_security)" +
                    " values ('" + sAccountID + "'," +
                    "'" + sAccountName + "'," +
                    "'" + sAccountNumber + "'," +
                    "'" + sProvider + "'," +
                    "'" + sIsDefault + "'," +
                    "'" + sLoginID + "'," +
                    "'" + dc.EnCrypt(sLoginPassword) + "'," +
                    "'" + sAutoManageSecurity + "')";

                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception("Error creating account: " + sErr);

                    ui.WriteObjectAddLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, "Account Created");
                }

                //if "default" was selected, unset all the others
                if (dc.IsTrue(sIsDefault))
                {
                    oTrans.Command.CommandText = "update cloud_account set is_default = 0 where account_id <> '" + sAccountID + "'";
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:cloudAccountEdit.aspx.cs


注:本文中的dataAccess.TestDBConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。