|
|
How to connect to MySQL 5.0. via C# .Net and the MySql Connector/Net |
This article and tutorial describes and demonstrates how you can connect to MySQL in a c# application.
-
-
Next create a new project
-
Next add reference to: MySql.Data
-
Next add "using MySql.Data.MySqlClient;"
-
Finally add the following code to your application:
private void button1_Click(object sender, System.EventArgs e) { string MyConString = "SERVER=localhost;" + "DATABASE=mydatabase;" + "UID=testuser;" + "PASSWORD=testpassword;"; MySqlConnection connection = new MySqlConnection(MyConString); MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; command.CommandText = "select * from mycustomers"; connection.Open(); Reader = command.ExecuteReader(); while (Reader.Read()) { string thisrow = ""; for (int i= 0;i<Reader.FieldCount;i++) thisrow+=Reader.GetValue(i).ToString() + ","; listBox1.Items.Add(thisrow); } connection.Close(); } |
|
|
|
| Highlighted Products |
|
|
Email Pack
BitDaddys Corp.
$39.95
More Info
Buy Now!
|
|
Email conversion and action pack. Get all of our powerful email utilities for one very low price! more ... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSV2DG
BitDaddys Corp.
$10.00
More Info
Free Trial
Buy Now!
|
|
Create, Edit, Import and Display CSV ( Comma Separated Values) files in an easy to use Data Grid with the ability to print, launch Excel or even launch a custom application. This application allows for quick edit and display of csv data in a format that allows for easy viewing, sorting and printing. You can also customize the apparent program name, company name, report title and visible options more... |
|
|
|
|
emlBridge
BitDaddys Corp.
$12.00
More Info
Free Trial
Buy Now!
|
|
Import eml Files into nearly any Email Client. With emlBridge you can import rfc822 standard text email files into programs like Outlook, Thunderbird and Outlook Express more ... |
|
|
|
|
MSGDETACH
BitDaddys Corp.
$14.00
More Info
Free Trial
Buy Now!
|
|
Detach Email Attachments from your Email and Save them wherever you want! Extract your message attachments from Outlook msg files. more ... |
|
|
|
|
|
|