Ejemplo n.º 1
0
        private void btnTestConn_Click(object sender, EventArgs e)
        {
            string connectionURI = "Data Source=" + txtHost.Text.Trim() + ";Initial Catalog= "
                                   + txtSID.Text.Trim() + "; user id="
                                   + EncryptService.SDecrypt(txtUserName.Text.Trim()) + ";password="******"Connect success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connect error", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogHelper.Error(ex);
            }
        }
Ejemplo n.º 2
0
        private DataAccessConfiguration ReadDataFromRegistry(string strParam)
        {
            DataAccessConfiguration daConfig = null;
            RegistryKey             rk;

            rk = Registry.CurrentUser;
            rk = rk.OpenSubKey(@"software\amtec\tte\" + strParam);
            if (rk != null)
            {
                string[] names   = rk.GetValueNames();
                string   strUser = "";
                string   strPWD  = "";
                string   strIP   = "";
                string   strPort = "";
                string   strSID  = "";
                string   strLock = "";
                foreach (var item in names)
                {
                    switch (item)
                    {
                    case "user":
                        strUser = rk.GetValue(item).ToString();
                        this.txtUserName.Text = strUser;
                        break;

                    case "pwd":
                        strPWD           = rk.GetValue(item).ToString();
                        this.txtPSW.Text = strPWD;
                        break;

                    case "ip":
                        strIP             = rk.GetValue(item).ToString();
                        this.txtHost.Text = strIP;
                        break;

                    case "port":
                        strPort           = rk.GetValue(item).ToString();
                        this.txtPort.Text = strPort;
                        break;

                    case "sid":
                        strSID           = rk.GetValue(item).ToString();
                        this.txtSID.Text = strSID;
                        break;

                    case "lock":
                        strLock = rk.GetValue(item).ToString();
                        if (string.IsNullOrEmpty(strLock))
                        {
                            this.radLock.Checked = true;
                        }
                        else if (strLock.ToUpper() == "TRUE")
                        {
                            this.radLock.Checked = true;
                        }
                        else if (strLock.ToUpper() == "FALSE")
                        {
                            this.radUnLock.Checked = true;
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (strParam == "ORACLE")
                {
                    daConfig            = new DataAccessConfiguration();
                    daConfig.ConfigName = strParam;
                    daConfig.DBType     = strParam;
                    string connectionURI = "user id=" + strUser + ";password="******";Data Source=" + strIP + ":" + strPort + @"/" + strSID;
                    daConfig.ConnectionString = connectionURI;
                }
                else if (strParam == "SQLServer")
                {
                    daConfig            = new DataAccessConfiguration();
                    daConfig.ConfigName = strParam;
                    daConfig.DBType     = strParam;
                    string connectionURI = "Data Source=" + strIP + ";Initial Catalog= "
                                           + strSID + "; user id="
                                           + EncryptService.SDecrypt(strUser) + ";password=" + EncryptService.SDecrypt(strPWD);
                    daConfig.ConnectionString = connectionURI;
                }
                rk.Close();
            }
            return(daConfig);
        }