有谁知道C#怎么连接phpMyAdmin数据库? phpMyAdmin是MYSQL的界面管理工具,不是数据库C#-MYSQL:http://www.albertsong.com/read-58.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 phpmyadmin管理mysqlhttp://www.cnblogs.com/mbskys/articles/633381.aspx 找c# 连mysql 数据库的资料。。 1.安装完MySQL后看看MySQL是否已经启动;2.在项目中添加引用MySql.Data.dll3.连接MySQLusing System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using MySql.Data.MySqlClient; private void ConnMySQLTest() { //连接字符串 string connStr = String.Format("server={0};uid={1};pwd={2};database={3}" , server.Text , uid.Text , pwd.Text , database.Text); conn = new MySqlConnection(connStr); try { //打开连接 conn.Open(); //你的SQL语句 string sql = "DROP TABLE IF EXISTS AsyncSampleTable; CREATE TABLE AsyncSampleTable (numVal int)"; cmd = new MySqlCommand(sql , conn); //执行SQL cmd.ExecuteNonQuery(); sql = "DROP PROCEDURE IF EXISTS AsyncSample;" + "CREATE PROCEDURE AsyncSample() BEGIN " + "set @x=0; repeat set @x=@x+1; until @x > 5000000 end repeat; " + "INSERT INTO AsyncSampleTable VALUES (1); end;"; cmd.CommandText = sql; cmd.ExecuteNonQuery(); cmd.CommandText = "AsyncSample"; cmd.CommandType = CommandType.StoredProcedure; asyncResult = cmd.BeginExecuteNonQuery(); nextTime = 5; timer1.Enabled = true; start = DateTime.Now; } catch ( Exception ex ) { MessageBox.Show("Exception: " + ex.Message);//连接错误时抛出错误信息 } }随便给你写了一个方法,作为参考,其实绝大多数关系数据库在.net中连接方式都很相似 关于netstream的read方法,求教 请教:仿照Google智能在线搜索建议的功能! 一个作业的问题,请帮忙 socket:如何用c#编写一个客户端和服务端互相通信 安装msde2000的时候出现的问题 remoting应用程序开发上速度的讨论! c#从oracle数据库中日期字段取出值 老风格(100分在线给)新闻的数据库用什么类型啊 插入ORACLE数据的问题 c/s程序连接sql server express 在发布时如何打包?谢谢~~~~~~~~~~· 求助!把下面VB的代码转换成C#的,万分感激! 有关命名空间引用的问题,求救!
http://www.cnblogs.com/mbskys/articles/633381.aspx
2.在项目中添加引用MySql.Data.dll
3.连接MySQL
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient; private void ConnMySQLTest()
{
//连接字符串
string connStr = String.Format("server={0};uid={1};pwd={2};database={3}" ,
server.Text , uid.Text , pwd.Text , database.Text);
conn = new MySqlConnection(connStr);
try
{
//打开连接
conn.Open();
//你的SQL语句 string sql = "DROP TABLE IF EXISTS AsyncSampleTable; CREATE TABLE AsyncSampleTable (numVal int)";
cmd = new MySqlCommand(sql , conn);
//执行SQL
cmd.ExecuteNonQuery(); sql = "DROP PROCEDURE IF EXISTS AsyncSample;" +
"CREATE PROCEDURE AsyncSample() BEGIN " +
"set @x=0; repeat set @x=@x+1; until @x > 5000000 end repeat; " +
"INSERT INTO AsyncSampleTable VALUES (1); end;";
cmd.CommandText = sql;
cmd.ExecuteNonQuery(); cmd.CommandText = "AsyncSample";
cmd.CommandType = CommandType.StoredProcedure; asyncResult = cmd.BeginExecuteNonQuery();
nextTime = 5;
timer1.Enabled = true;
start = DateTime.Now;
}
catch ( Exception ex )
{
MessageBox.Show("Exception: " + ex.Message);//连接错误时抛出错误信息
}
}
随便给你写了一个方法,作为参考,其实绝大多数关系数据库在.net中连接方式都很相似