public string Con_str() { Con_string c_str = new Con_string(); RegistryKey myreg; myreg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\PictureBox\\Setting", true); if (myreg != null) { if ((myreg.ValueCount > 3) && ((string)myreg.GetValue("Server") != "")) { c_str.Data_Source = (string)myreg.GetValue("Server"); if ((string)myreg.GetValue("dbf") == "Нет") { c_str.Remote_add = true; } else { c_str.Remote_add = false; } c_str.AttachDbFilename = (string)myreg.GetValue("path_dbf"); c_str.Database = (string)myreg.GetValue("database"); if ((string)myreg.GetValue("ayth") == "Аутентификация Windows") { c_str.Integrated_Security = true; } else { c_str.Integrated_Security = false; } c_str.User_ID = (string)myreg.GetValue("login"); string pass = ""; string new_pass = ""; pass = (string)myreg.GetValue("pass"); int ppp; for (int i = 0; i < pass.Length; i++) { ppp = (int)pass[i] - i; new_pass += (char)ppp; } c_str.User_pass = new_pass; } else { return("error"); } } else { return("error"); } myreg.Close(); string first = "Data Source="; first = first + c_str.Data_Source + ";"; if (!c_str.Remote_add) { first = first + "AttachDbFilename=" + c_str.AttachDbFilename + ";"; } else { first = first + "Database=" + c_str.Database + ";"; } if (!c_str.Integrated_Security) { first = first + "Integrated Security=false;"; first = first + "User ID=" + c_str.User_ID + ";"; first = first + "Password="******";"; } else { first = first + "Integrated Security=true;"; } return(first); }
public string Con_str() { Con_string c_str = new Con_string(); RegistryKey myreg; myreg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\AgroMeteo\\ConnectionSetting", true); if (myreg != null) { if ((myreg.ValueCount > 3) && ((string)myreg.GetValue("Server")!="")) { c_str.Data_Source = (string)myreg.GetValue("Server"); if ((string)myreg.GetValue("dbf") == "Нет") c_str.Remote_add = true; else c_str.Remote_add = false; c_str.AttachDbFilename = (string)myreg.GetValue("path_dbf"); c_str.Database = (string)myreg.GetValue("database"); if ((string)myreg.GetValue("ayth") == "Аутентификация Windows") c_str.Integrated_Security = true; else c_str.Integrated_Security = false; c_str.User_ID = (string)myreg.GetValue("login"); string pass = ""; string new_pass = ""; pass = (string)myreg.GetValue("pass"); int ppp; for (int i = 0; i < pass.Length; i++) { ppp = (int)pass[i] - i; new_pass += (char)ppp; } c_str.User_pass = new_pass; } else { return "error"; } } else { return "error"; } myreg.Close(); string first = "Data Source="; first = first + c_str.Data_Source+";"; if (!c_str.Remote_add) { first = first + "AttachDbFilename=" + c_str.AttachDbFilename + ";"; } else { first = first + "Database=" + c_str.Database + ";"; } if (!c_str.Integrated_Security) { first = first + "Integrated Security=false;"; first = first + "User ID=" + c_str.User_ID + ";"; first = first + "Password="******";"; } else { first = first + "Integrated Security=true;"; } return first; }