This article covers how to talk to MySQL database and extract the schema from it.
Background
As many of you know Authentic Dellin Betances Jersey , MySQL is an open source database. It is free for non-commercial purposes. This article would be helpful for anybody doing development in MySQL and C#. What is the motivation behind this utility? Well, an application could crash in the middle of database activities. Often, these databases may not reside on the same site as your developmenttesting machine. We need a utility that would help us get a snapshot of the database at client site. If you have an utility that would capture the state of the client database Authentic Sonny Gray Jersey , then, you can load it in your testing machine. The idea is to reproduce the situation your client faced. That way you can address any undiscovered issues.
Functionality Supported
Saving Schema as Text Viewing Schema Viewing Entire Database
Required Tools
ODBC.NET Data Provider from Microsoft MySQL Database MySQL ODBC Connector
Using the code
First, add a reference to Microsoft ODBC. Then use the using microsoft.odbc statement to tell it that you want to you MS ODBC. In short Authentic Aroldis Chapman Jersey , OdbcConnection will be used to open connection, OdbcCommand to execute queries, and OdbcDataReader to read the resulting row set. The code shown below documents each step. You will notice Authentic C.C. Sabathia Jersey , it runs the MySQL specific command SHOW TABLES to get the list of tables. Then it runs another query based on that particular table, SHOW COLUMNS IN CURRENT_TABLE. This is all the code does.
The Code
Collapse *
@@ Function: @f ::PrepareSchema
@@ Description: @d when this is called the widget is updated and everything about this database and tables are displayed
@@ Type: @t public
@@ Arguments: none. @@ Returns: @r void
@@ Preconditions: @c Provided that the GUI is running and DB Connection is made.
@@ Postconditions: @o DB schema displayed
@@ References: @e Query MySql with C#.
*
public void PrepareSchema() { create the connection object by setting the DSN
OdbcConnection ocConnection = new OdbcConnection("DSN="+ strDSN);
second connection is created so we could make
queries while executing one
OdbcConnection ocConnection2 = new OdbcConnection("DSN="+ strDSN);
if (!strColumnNull.Equals("YES")) strColumnNull = " NOT NULL "; else strColumnNull = "";
if (strColumnPKey.Equals("PRI")) strColumnPKey = " PRIMARY KEY ";
this.rchtxtSchema.Text += "n"; A POC or perhaps portable oxygen concentrator is known as an unit Authentic Derek Jeter Jersey , that is utilized so as to offer a patient with oxygen therapy that will surpasses the power of atmospheric air. These are alike in frame and use to home-based oxygen concentrator but are scaled-down as well as, subsequently, extra transportable. This allows for patients to travel in addition to move together with the self-assuran.