Commit d10ea431 authored by Jake Oandasan's avatar Jake Oandasan

Commit project dependencies and add MySql Connector/ODBC on installer

parent 7ed73c3f
#For the meantime
IT\ MAX\ DB\ Setup/Resources/*
Application/Resources/*
Application/Resources/bcscrm5.mdb
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
......
......@@ -8,18 +8,25 @@
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="IT MAX DB" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="INSTALLFOLDER_Permission" />
<ComponentRef Id="bcscrm5.mdb" />
<ComponentRef Id="vbSendMail.dll" />
<ComponentRef Id="MSWINSCK.OCX" />
<ComponentRef Id="ApplicationShortcutDesktop"/>
</Feature>
</Product>
<Fragment>
<!-- DECLARE THE DIRECTORY STRUCTURE -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- INSTALLATION PATH -->
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="IT MAX DB">
</Directory>
</Directory>
<!-- DESKTOP SHORTCUT -->
<Directory Id="DesktopFolder" Name="Desktop"/>
</Directory>
<!-- SET DIRECTORY PERMISSION -->
......@@ -33,19 +40,99 @@
</Fragment>
<!-- DECLARE THE COMPONENTS TO BE INSTALLED -->
<!-- ACCESS FILE -->
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="bcscrm5.mdb" Guid="54bdb556-82a7-4b0c-8214-39445f399639" Win64="no">
<Component Id="bcscrm5.mdb" Guid="54bdb556-82a7-4b0c-8214-39445f399639" Win64="no" Directory="INSTALLFOLDER">
<File Id="bcscrm5.mdb" Name="bcscrm5.mdb" Source="Resources\bcscrm5.mdb"/>
</Component>
</Fragment>
<Component Id="vbSendMail.dll" Guid="d5c58ff4-5be2-45a7-8d95-b48842e4acf0" Win64="no">
<File Id="vbSendMail.dll" Name="vbSendMail.dll" Source="Resources\vbSendMail.dll"/>
<!-- VBSENDMAIL.DLL -->
<!-- THIS IS THE PROPER WAY OF REGISTERING THE DLL USING WIX (RegSvr32) -->
<!-- SO THAT IT CAN HANDLE THE UNREGISTERING OF DLL ONCE THE APPLICATION IS UNINSTALLED -->
<!-- YOU CAN OBTAIN THIS CODE BY RUNING HEAT.EXE ON CMD -->
<!-- heat.exe file "C:\vbSendMail.dll" -dr INSTALLFOLDER -srd -gg -sfrag -suid -svb6 -out "C:\vbSendMail.wxs" -->
<!-- OPEN THE vbSendMail.wxs THEN PASTE THE CODE IN HERE -->
<Fragment>
<Component Id="vbSendMail.dll" Guid="{521AD32B-0A0D-4386-BD8C-853ABD3A3AE9}" Directory="INSTALLFOLDER">
<File Id="vbSendMail.dll" KeyPath="yes" Source="Resources\vbSendMail.dll">
<TypeLib Id="{332B82D3-3ED6-11D4-B1B5-00105AA5CCFF}" Description="SMTP Send Mail for VB6.0" HelpDirectory="INSTALLFOLDER" Language="0" MajorVersion="5" MinorVersion="7">
<Class Id="{332B82DC-3ED6-11D4-B1B5-00105AA5CCFF}" Context="InprocServer32" Description="vbSendMail.clsSendMail" ThreadingModel="apartment" Version="5.7" Programmable="yes">
<ProgId Id="vbSendMail.clsSendMail" Description="vbSendMail.clsSendMail" />
</Class>
<Interface Id="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
<Interface Id="{23606E08-FB96-4A4C-8A49-E03878678873}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{2FB776FC-F628-4B66-A418-C9285055B285}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{4196C56F-7EB4-11D4-B1B5-00105AA5CCFF}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{4196C570-7EB4-11D4-B1B5-00105AA5CCFF}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{55C904F2-85EB-4982-BF62-C97108367B3A}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{95FAF493-3FB1-11D4-B1B5-00105AA5CCFF}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{95FAF497-3FB1-11D4-B1B5-00105AA5CCFF}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{A205B565-B13A-48B6-A2A3-5A6ED5E7295E}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{C3336FA5-6A1C-11D4-A8C0-005004668A89}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{C3336FA6-6A1C-11D4-A8C0-005004668A89}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{C5AAF5E5-4C5F-4917-8465-DACB00C4F3B2}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{D3CC98BD-79A8-4935-A32B-D6D6B464DB01}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{E858C8AD-D19F-4913-9DF5-40DA9E964915}" Name="clsSendMail" ProxyStubClassId="{00020420-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
<Interface Id="{FFCD78CD-A9BB-4E9D-BE92-EF4C60123D0C}" Name="clsSendMail" ProxyStubClassId="{00020424-0000-0000-C000-000000000046}" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<RegistryValue Root="HKCR" Key="CLSID\{332B82DC-3ED6-11D4-B1B5-00105AA5CCFF}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{23606E08-FB96-4A4C-8A49-E03878678873}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{2FB776FC-F628-4B66-A418-C9285055B285}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{4196C56F-7EB4-11D4-B1B5-00105AA5CCFF}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{4196C570-7EB4-11D4-B1B5-00105AA5CCFF}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{55C904F2-85EB-4982-BF62-C97108367B3A}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{95FAF493-3FB1-11D4-B1B5-00105AA5CCFF}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{95FAF497-3FB1-11D4-B1B5-00105AA5CCFF}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{A205B565-B13A-48B6-A2A3-5A6ED5E7295E}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{C3336FA5-6A1C-11D4-A8C0-005004668A89}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{C3336FA6-6A1C-11D4-A8C0-005004668A89}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{C5AAF5E5-4C5F-4917-8465-DACB00C4F3B2}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{D3CC98BD-79A8-4935-A32B-D6D6B464DB01}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{E858C8AD-D19F-4913-9DF5-40DA9E964915}\Forward" Value="{60678E4B-98F4-4F62-9FF7-2F6D77CF434B}" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="Interface\{FFCD78CD-A9BB-4E9D-BE92-EF4C60123D0C}\Forward" Value="{909E85D1-A062-4952-9FC0-B84367BB3F74}" Type="string" Action="write" />
</Component>
</Fragment>
<Component Id="MSWINSCK.OCX" Guid="6fc520df-6b30-4aef-acea-7f9076dc802d" Win64="no">
<File Id="MSWINSCK.OCX" Name="MSWINSCK.OCX" Source="Resources\MSWINSCK.OCX"/>
<!-- MSWINSCK.OCX -->
<!-- SLIGHTLY DIFFERENT CODE -->
<!-- heat.exe file "C:\MSWINSCK.OCX" -dr INSTALLFOLDER -srd -gg -sfrag -suid -out "C:\MSWINSCK.wxs" -->
<Fragment>
<Component Id="MSWINSCK.OCX" Guid="{FBAAF01D-FD1D-4560-A91B-B01B1A9D2A8F}" Directory="INSTALLFOLDER">
<File Id="MSWINSCK.OCX" KeyPath="yes" Source="Resources\MSWINSCK.OCX">
<Class Id="{248DD897-BB45-11CF-9ABC-0080C7E7B78D}" Context="InprocServer32" Description="Winsock General Property Page Object" />
<TypeLib Id="{248DD890-BB45-11CF-9ABC-0080C7E7B78D}" Control="yes" Description="Microsoft Winsock Control 6.0" HelpDirectory="INSTALLFOLDER" Language="0" MajorVersion="1" MinorVersion="0">
<Class Id="{248DD896-BB45-11CF-9ABC-0080C7E7B78D}" Context="InprocServer32" Description="Microsoft WinSock Control, version 6.0" ThreadingModel="apartment" Version="1.0" Programmable="yes" Control="yes">
<ProgId Id="MSWinsock.Winsock.1" Description="Microsoft WinSock Control, version 6.0">
<ProgId Id="MSWinsock.Winsock" Description="Microsoft WinSock Control, version 6.0" />
</ProgId>
</Class>
<Interface Id="{248DD892-BB45-11CF-9ABC-0080C7E7B78D}" Name="IMSWinsockControl" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{248DD893-BB45-11CF-9ABC-0080C7E7B78D}" Name="DMSWinsockControlEvents" ProxyStubClassId32="{00020420-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\Implemented Categories\{0DE86A52-2BAA-11CF-A229-00AA003D7352}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\Implemented Categories\{0DE86A53-2BAA-11CF-A229-00AA003D7352}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\Implemented Categories\{0DE86A57-2BAA-11CF-A229-00AA003D7352}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\Implemented Categories\{40FC6ED4-2438-11CF-A3DB-080036F12502}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\Implemented Categories\{40FC6ED5-2438-11CF-A3DB-080036F12502}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\MiscStatus\1" Value="132497" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\MiscStatus" Value="0" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{248DD896-BB45-11CF-9ABC-0080C7E7B78D}\ToolboxBitmap32" Value="[!MSWINSCK.OCX], 1" Type="string" Action="write" />
</Component>
</Fragment>
<!-- DESKTOP SHORTCUT LINK -->
<Fragment>
<Component Id="ApplicationShortcutDesktop" Guid="*" Directory="DesktopFolder">
<Shortcut Id="ApplicationDesktopShortcut"
Name="IT MAX DB"
Target="[#bcscrm5.mdb]"
WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software/IT MAX DB" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
......@@ -6,24 +6,41 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "IT MAX DB Setup", "IT MAX DB Setup\IT MAX DB Setup.wixproj", "{3DA729EB-467E-4D86-87B6-9930877F09A1}"
ProjectSection(ProjectDependencies) = postProject
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0} = {706ADD1A-15B5-464D-AFDD-CD1D58039AB0}
{5FFF12D9-8236-439A-ACC5-0A1E676AB766} = {5FFF12D9-8236-439A-ACC5-0A1E676AB766}
EndProjectSection
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Application", "Application\Application.wixproj", "{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODBCManager", "ODBCManager\ODBCManager.csproj", "{5FFF12D9-8236-439A-ACC5-0A1E676AB766}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3DA729EB-467E-4D86-87B6-9930877F09A1}.Debug|Any CPU.ActiveCfg = Debug|x86
{3DA729EB-467E-4D86-87B6-9930877F09A1}.Debug|x86.ActiveCfg = Debug|x86
{3DA729EB-467E-4D86-87B6-9930877F09A1}.Debug|x86.Build.0 = Debug|x86
{3DA729EB-467E-4D86-87B6-9930877F09A1}.Release|Any CPU.ActiveCfg = Release|x86
{3DA729EB-467E-4D86-87B6-9930877F09A1}.Release|x86.ActiveCfg = Release|x86
{3DA729EB-467E-4D86-87B6-9930877F09A1}.Release|x86.Build.0 = Release|x86
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}.Debug|Any CPU.ActiveCfg = Debug|x86
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}.Debug|x86.ActiveCfg = Debug|x86
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}.Debug|x86.Build.0 = Debug|x86
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}.Release|Any CPU.ActiveCfg = Release|x86
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}.Release|x86.ActiveCfg = Release|x86
{706ADD1A-15B5-464D-AFDD-CD1D58039AB0}.Release|x86.Build.0 = Release|x86
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Debug|x86.ActiveCfg = Release|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Debug|x86.Build.0 = Release|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Release|Any CPU.Build.0 = Release|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Release|x86.ActiveCfg = Release|Any CPU
{5FFF12D9-8236-439A-ACC5-0A1E676AB766}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle Name="IT MAX DB Setup" Version="1.0.0.0" Manufacturer="IT MAX" UpgradeCode="3da729eb-467e-4d86-87b6-9930877f09a1">
<Bundle Name="IT MAX DB" Version="1.0.0.0" Manufacturer="IT MAX" UpgradeCode="3da729eb-467e-4d86-87b6-9930877f09a1">
<!-- SHOW AN EMPTY LICENSE -->
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense"/>
<WixVariable Id="WixStdbaLicenseUrl" Value=""/>
......@@ -21,32 +21,47 @@
<ExePackage SourceFile="Resources\vcredist_x86.exe"
Id="Visual_C_plus_plus_Redistributable"
Name="Visual C++ Redistributable"
DisplayName="Visual C++ Redistributable x86"
PerMachine="yes"
InstallCondition="NOT VisualCPPRedistExists"/>
InstallCondition="NOT VisualCPPRedistExists"
InstallCommand="/quiet"/>
<!-- MYSQL CONNECTOR -->
<MsiPackage SourceFile="Resources\mysql-connector-odbc-5.3.14-win32.msi"
Id="MySQL_Connector"
Name="MySQL Connector"
InstallCondition="NOT MySQLConnectorExists"/>
InstallCondition="NOT MySQLConnectorExists"
DisplayName="MySQL Connector ODBC x86"
DisplayInternalUI="no"/>
<!-- ACCESS RUNTIME -->
<MsiPackage SourceFile="Resources\ACCESSRT.MSI"
Id="Access_Runtime"
Name="Access Runtime"
InstallCondition="NOT AccessRuntimeExists"/>
InstallCondition="NOT AccessRuntimeExists"
DisplayName="Microsoft Office Access Runtime 2003"
DisplayInternalUI="no"/>
<!-- OFFICE 2003 SP3 -->
<ExePackage SourceFile="Resources\Office2003SP3-KB923618-FullFile-DEU.exe"
Id="Office_2003_Service_Pack_3"
Name="Office 2003 Service Pack 3"
PerMachine="yes"/>
DisplayName="Office 2003 Service Pack 3 (KB923618)"
PerMachine="yes"
InstallCommand="/q"/>
<!-- END PREREQUISITE APPLICATIONS -->
<!-- MAIN APPLICATION -->
<MsiPackage SourceFile="..\Application\bin\Debug\IT MAX DB.msi"
Id="IT_MAX_DB"
Name="IT MAX DB"/>
Name="IT MAX DB" DisplayName="IT MAX DB"
DisplayInternalUI="no"/>
<!-- ODBC DATA -->
<ExePackage SourceFile="..\ODBCManager\bin\Release\ODBCManager.exe"
Id="ODBC_Manager"
Name="ODBC_Manager"
DisplayName="Input MySQL/ODBC DataSource"/>
</Chain>
</Bundle>
</Wix>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
namespace ODBCManager
{
partial class MySQLConnectorForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label2 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtUser = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtDataSource = new System.Windows.Forms.TextBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.txtPort = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtTCPIP = new System.Windows.Forms.TextBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.cmbDatabase = new System.Windows.Forms.ComboBox();
this.btnTest = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.SystemColors.Control;
this.groupBox1.Controls.Add(this.btnCancel);
this.groupBox1.Controls.Add(this.btnOK);
this.groupBox1.Controls.Add(this.tableLayoutPanel1);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(20, 20);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(10, 15, 10, 10);
this.groupBox1.Size = new System.Drawing.Size(335, 266);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection Parameters";
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(172, 220);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 21;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(70, 220);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 20;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F));
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.label6, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.txtPassword, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.label5, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.txtUser, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.label4, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.txtDataSource, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 4);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top;
this.tableLayoutPanel1.Location = new System.Drawing.Point(10, 29);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 5;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(315, 168);
this.tableLayoutPanel1.TabIndex = 19;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(5, 36);
this.label2.Margin = new System.Windows.Forms.Padding(5);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 14);
this.label2.TabIndex = 2;
this.label2.Text = "TCP/IP Server:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(5, 134);
this.label6.Margin = new System.Windows.Forms.Padding(5);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(61, 14);
this.label6.TabIndex = 10;
this.label6.Text = "Database:";
//
// txtPassword
//
this.txtPassword.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtPassword.Font = new System.Drawing.Font("Tahoma", 8.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtPassword.Location = new System.Drawing.Point(134, 103);
this.txtPassword.Margin = new System.Windows.Forms.Padding(8, 5, 5, 5);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(176, 21);
this.txtPassword.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(5, 103);
this.label5.Margin = new System.Windows.Forms.Padding(5);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(62, 14);
this.label5.TabIndex = 8;
this.label5.Text = "Password:";
//
// txtUser
//
this.txtUser.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtUser.Location = new System.Drawing.Point(134, 72);
this.txtUser.Margin = new System.Windows.Forms.Padding(8, 5, 5, 5);
this.txtUser.Name = "txtUser";
this.txtUser.Size = new System.Drawing.Size(176, 21);
this.txtUser.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(5, 72);
this.label4.Margin = new System.Windows.Forms.Padding(5);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(35, 14);
this.label4.TabIndex = 6;
this.label4.Text = "User:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(5, 5);
this.label1.Margin = new System.Windows.Forms.Padding(5);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(109, 14);
this.label1.TabIndex = 1;
this.label1.Text = "DataSource Name:";
//
// txtDataSource
//
this.txtDataSource.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtDataSource.Location = new System.Drawing.Point(134, 5);
this.txtDataSource.Margin = new System.Windows.Forms.Padding(8, 5, 5, 5);
this.txtDataSource.Name = "txtDataSource";
this.txtDataSource.ReadOnly = true;
this.txtDataSource.Size = new System.Drawing.Size(176, 21);
this.txtDataSource.TabIndex = 2;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 3;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel2.Controls.Add(this.txtPort, 2, 0);
this.tableLayoutPanel2.Controls.Add(this.label3, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.txtTCPIP, 0, 0);
this.tableLayoutPanel2.Location = new System.Drawing.Point(129, 34);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.Size = new System.Drawing.Size(183, 30);
this.tableLayoutPanel2.TabIndex = 15;
//
// txtPort
//
this.txtPort.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtPort.Location = new System.Drawing.Point(141, 5);
this.txtPort.Margin = new System.Windows.Forms.Padding(5);
this.txtPort.Name = "txtPort";
this.txtPort.ReadOnly = true;
this.txtPort.Size = new System.Drawing.Size(37, 21);
this.txtPort.TabIndex = 17;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(96, 5);
this.label3.Margin = new System.Windows.Forms.Padding(5);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(34, 14);
this.label3.TabIndex = 16;
this.label3.Text = "Port:";
//
// txtTCPIP
//
this.txtTCPIP.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtTCPIP.Location = new System.Drawing.Point(5, 5);
this.txtTCPIP.Margin = new System.Windows.Forms.Padding(5);
this.txtTCPIP.Name = "txtTCPIP";
this.txtTCPIP.Size = new System.Drawing.Size(81, 21);
this.txtTCPIP.TabIndex = 3;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.cmbDatabase);
this.flowLayoutPanel1.Controls.Add(this.btnTest);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(129, 132);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(183, 36);
this.flowLayoutPanel1.TabIndex = 16;
//
// cmbDatabase
//
this.cmbDatabase.FormattingEnabled = true;
this.cmbDatabase.Location = new System.Drawing.Point(5, 5);
this.cmbDatabase.Margin = new System.Windows.Forms.Padding(5);
this.cmbDatabase.Name = "cmbDatabase";
this.cmbDatabase.Size = new System.Drawing.Size(125, 21);
this.cmbDatabase.TabIndex = 11;
this.cmbDatabase.DropDown += new System.EventHandler(this.cmbDatabase_DropDown);
//
// btnTest
//
this.btnTest.Location = new System.Drawing.Point(138, 3);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(40, 23);
this.btnTest.TabIndex = 22;
this.btnTest.Text = "Test";
this.btnTest.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// MySQLConnectorForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(375, 306);
this.Controls.Add(this.groupBox1);
this.Font = new System.Drawing.Font("Tahoma", 8.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "MySQLConnectorForm";
this.Padding = new System.Windows.Forms.Padding(20);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MySQL Connector";
this.Load += new System.EventHandler(this.MySQLConnectorForm_Load);
this.groupBox1.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox cmbDatabase;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtUser;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtDataSource;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtTCPIP;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button btnTest;
}
}
\ No newline at end of file
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
namespace ODBCManager
{
public partial class MySQLConnectorForm : Form
{
private string MySQLODBCAnsiDriver = "MySQL ODBC 5.3 ANSI Driver";
private string DefaultDataSourceName = "IT-MAX-MUC";
private string DefaultMySQLPort = "3306";
public MySQLConnectorForm()
{
InitializeComponent();
}
private void MySQLConnectorForm_Load(object sender, EventArgs e)
{
// Check if the default DataSourceName exists
if (MySQLODBCManager.DataSourceNameExists(DefaultDataSourceName))
{
Dictionary<string, string> dataSourceValues = MySQLODBCManager.GetDataSourceValues(DefaultDataSourceName);
// Load the DataSource values
txtDataSource.Text = DefaultDataSourceName;
txtTCPIP.Text = dataSourceValues[MySQLODBCManager.MySQLODBCFields.SERVER.ToString()];
txtPort.Text = dataSourceValues[MySQLODBCManager.MySQLODBCFields.PORT.ToString()];
txtUser.Text = dataSourceValues[MySQLODBCManager.MySQLODBCFields.UID.ToString()];
txtPassword.Text = dataSourceValues[MySQLODBCManager.MySQLODBCFields.PWD.ToString()];
cmbDatabase.Text = dataSourceValues[MySQLODBCManager.MySQLODBCFields.DATABASE.ToString()];
}
else
{
// Just fill up the default values
txtDataSource.Text = DefaultDataSourceName;
txtPort.Text = DefaultMySQLPort;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
// Create the new DataSource
MySQLODBCManager.CreateSystemDataSourceName(
driverName: MySQLODBCAnsiDriver,
dataSourceName: txtDataSource.Text,
server: txtTCPIP.Text,
port: txtPort.Text,
user: txtUser.Text,
password: txtPassword.Text,
database: cmbDatabase.Text);
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}
private void btnTest_Click(object sender, EventArgs e)
{
// Execute the connection test on a different thread
BackgroundWorker worker = new BackgroundWorker();
string tcpip = txtTCPIP.Text;
string port = txtPort.Text;
string user = txtUser.Text;
string password = txtPassword.Text;
string database = (string.IsNullOrWhiteSpace(cmbDatabase.Text) ? "mysql" : cmbDatabase.Text);
worker.DoWork += (obj, se) =>
{
MySQLODBCManager.TestConnection(
driver: MySQLODBCAnsiDriver,
server: tcpip,
port: port,
user: user,
password: password,
database: database);
};
worker.RunWorkerAsync();
}
private void cmbDatabase_DropDown(object sender, EventArgs e)
{
List<string> databases = new List<string>();
string tcpip = txtTCPIP.Text;
string port = txtPort.Text;
string user = txtUser.Text;
string password = txtPassword.Text;
//get the list of databases
databases = MySQLODBCManager.GetDatabases(
driver: MySQLODBCAnsiDriver,
server: tcpip,
port: port,
user: user,
password: password);
//clear and reload the dropdown
cmbDatabase.Items.Clear();
cmbDatabase.Items.AddRange(databases.ToArray());
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
using System;
using Microsoft.Win32;
using System.Collections.Generic;
using System.Data.Odbc;
using System.Windows.Forms;
namespace ODBCManager
{
//A static class which can be used to add, update, delete MySQL ODBC entry
public static class MySQLODBCManager
{
//Enum to represent the registry name of datasource entry values
public enum MySQLODBCFields
{
DATABASE,
Driver,
PORT,
PWD,
SERVER,
UID
}
//Registry path of ODBC entries
private const string ODBC_INI_REG_PATH = "SOFTWARE\\ODBC\\ODBC.INI\\";
private const string ODBCINST_INI_REG_PATH = "SOFTWARE\\ODBC\\ODBCINST.INI\\";
//Creates a new System MySQL DataSource entry with the specified values. If the DSN exists, the values are updated.
public static void CreateSystemDataSourceName(string driverName, string dataSourceName, string server, string port, string user, string password, string database)
{
//Lookup driver path from driver name
RegistryKey driverKey = Registry.LocalMachine.CreateSubKey(ODBCINST_INI_REG_PATH + driverName);
if (driverKey == null) throw new Exception(string.Format("ODBC Registry key for driver '{0}' does not exist", driverName));
string driverPath = driverKey.GetValue("Driver").ToString();
//Add value to odbc data sources
RegistryKey datasourcesKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + "ODBC Data Sources");
if (datasourcesKey == null) throw new Exception("ODBC Registry key for datasources does not exist");
datasourcesKey.SetValue(dataSourceName, driverName);
//Create new key in odbc.ini with dsn name and add values
RegistryKey dsnKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + dataSourceName);
if (dsnKey == null) throw new Exception("ODBC Registry key for DSN was not created");
dsnKey.SetValue(MySQLODBCFields.DATABASE.ToString(), database);
dsnKey.SetValue(MySQLODBCFields.Driver.ToString(), driverPath);
dsnKey.SetValue(MySQLODBCFields.PORT.ToString(), port);
dsnKey.SetValue(MySQLODBCFields.PWD.ToString(), password);
dsnKey.SetValue(MySQLODBCFields.SERVER.ToString(), server);
dsnKey.SetValue(MySQLODBCFields.UID.ToString(), user);
}
//Load the value of DataSource
public static Dictionary<string, string> GetDataSourceValues(string dataSourceName)
{
Dictionary<string, string> dataSourceValues = new Dictionary<string, string>();
//Check if datasource exists
if (DataSourceNameExists(dataSourceName))
{
RegistryKey dsnKey = Registry.LocalMachine.OpenSubKey(ODBC_INI_REG_PATH + dataSourceName);
if (dsnKey != null)
{
//loop through enums
foreach(var mySQLField in Enum.GetValues(typeof(MySQLODBCFields)))
//store the value of datasource subkey in the dictionary
dataSourceValues.Add(mySQLField.ToString(), dsnKey.GetValue(mySQLField.ToString()).ToString());
}
}
return dataSourceValues;
}
//Removes a DataSourceName entry
public static void RemoveDataSourceName(string dataSourceName)
{
//Remove DataSourceName on registry
Registry.LocalMachine.DeleteSubKeyTree(ODBC_INI_REG_PATH + dataSourceName);
//Remove DataSourceName from values list in ODBC Data Sources key
RegistryKey datasourcesKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + "ODBC Data Sources");
if (datasourcesKey == null) throw new Exception("ODBC Registry key for datasources does not exist");
datasourcesKey.DeleteValue(dataSourceName);
}
// Checks the registry to see if a DataSourceName exists with the specified name
public static bool DataSourceNameExists(string dataSourceName)
{
bool retval = false;
string DSNPath = "";
try
{
RegistryKey dsnKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH, RegistryKeyPermissionCheck.ReadSubTree);
if (dsnKey.OpenSubKey(dataSourceName) != null)
{
DSNPath = dsnKey.OpenSubKey(dataSourceName).Name;
if (DSNPath.Equals(dsnKey.Name + @"\" + dataSourceName))
{
retval = true;
}
}
}
catch (Exception ex)
{
throw ex;
}
return retval;
}
// Method to check the connectivity on MySQL Server
public static void TestConnection(string driver, string server, string port, string user, string password, string database)
{
// Build connection string
string connectionString = string.Format("Driver={0};Server={1};Port={2};Database={3};uid={4};pwd={5};Option=3;",
"{" + driver + "}", server, port, string.IsNullOrWhiteSpace(database) ? "mysql" : database, user, password);
// Check if the connection can be opened
using (OdbcConnection mySQLConnection = new OdbcConnection(connectionString))
{
try
{
mySQLConnection.Open();
if (mySQLConnection.State == System.Data.ConnectionState.Open)
MessageBox.Show("Connection Successful", "Test Result");
}
catch (Exception ex)
{
MessageBox.Show("Connection Failed\n" + ex.Message, "Test Result");
}
}
}
// Function to read all the databases on MySQL Server
public static List<string> GetDatabases(string driver, string server, string port, string user, string password)
{
List<string> databases = new List<string>();
// Build connection string
string connectionString = string.Format("Driver={0};Server={1};Port={2};uid={3};pwd={4};Option=3;",
"{" + driver + "}", server, port, user, password);
// Open connection, execute command and store in list
using (OdbcConnection mySQLConnection = new OdbcConnection(connectionString))
{
mySQLConnection.Open();
using (OdbcCommand command = new OdbcCommand("show databases;", mySQLConnection))
{
using (OdbcDataReader reader = command.ExecuteReader())
{
while (reader.Read())
databases.Add(reader.GetValue(0).ToString());
}
}
}
return databases;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5FFF12D9-8236-439A-ACC5-0A1E676AB766}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ODBCManager</RootNamespace>
<AssemblyName>ODBCManager</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MySQLConnectorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MySQLConnectorForm.Designer.cs">
<DependentUpon>MySQLConnectorForm.cs</DependentUpon>
</Compile>
<Compile Include="MySQLODBCManager.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MySQLConnectorForm.resx">
<DependentUpon>MySQLConnectorForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ODBCManager
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MySQLConnectorForm());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ODBCManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ODBCManager")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5fff12d9-8236-439a-acc5-0a1e676ab766")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ODBCManager.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ODBCManager.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ODBCManager.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment