using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using MySql.Data.MySqlClient;
namespace DatabaseProject
{
public class MySqlTest
{
public void Test() {
try {
//string connectionString = "Provider=MySQLPov;server=localhost;user id=root;password=godoro;database=test";
//OleDbConnection connection = new OleDbConnection(connectionString);
string connectionString = "server=localhost;user id=root;password=godoro;database=test";
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
Console.WriteLine("Connected to mySQL Server");
String sql = "select * from TestTable";
MySqlCommand command = new MySqlCommand(sql, connection);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read()) {
int testId = reader.GetInt32("TestId");
string testName = reader.GetString("TestName");
Console.WriteLine(testId+ " , " + testName);
}
reader.Close();
connection.Close();
Console.WriteLine("Disconnected from mySQL Server");
} catch (Exception e) {
Console.WriteLine(e);
}
}
}
}
Dosyayı İndir