Page 1 of 1

Simple MySQL Connector/NET in Phalanger

PostPosted: May 30th, 2011, 2:53 am
by kielsoft
This is a simple way to use MySQL Connector/NET with Phalanger

Note:
1. Add 'MySql.Data' Assemply to your project from Solution Panel,(Download and install from here)
2. Add a DataGridView to your form and call it 'dataGridView1'.
3. Tested and OK in Visual Studio 2010.



// add the below Namespace
import namespace System;import namespace System:::Data;import namespace MySql:::Data;import namespace MySql:::Data:::MySqlClient;// ........// ........//Onload of Form1private function Form1_Load(System:::Object $sender, System:::EventArgs $e) { $connStr = "server=localhost;user=root;database=cicot;port=3306;password=;"; $conn = new MySqlConnection($connStr); $sql = "SELECT * from StudentData"; $daStudentData = new MySqlDataAdapter ($sql, $conn); $cb = new MySqlCommandBuilder($daStudentData); $dsStudentData = new DataSet(); $daStudentData->Fill($dsStudentData, "StudentData"); $this->dataGridView1->DataSource = $dsStudentData; $this->dataGridView1->DataMember = "StudentData";}

for more info about MySQL Connector/NET see http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-intro.html