在C#.net程序中使用MYSQL数据库
下面是commond:
MySQLCommand cmd;
cmd = new MySQLDriverCS.MySQLCommand("DROP TABLE IF EXISTS test.mysqldrivercs_test",conn);
cmd.ExecuteNonQuery();
cmd.Dispose();
下面是insert:
string Value = "Value";
int SettingID = 1;
new MySQLInsertCommand(conn,
new object[,] {{"SettingID",SettingID},{"SettingValue",Value}},
"mysqldrivercs_test");
下面是update
Value = "Value2";
new MySQLUpdateCommand(conn,
new object[,] {{"SettingValue",Value}},
"mysqldrivercs_test",
new object[,] {{"SettingID","=",SettingID}},
null);
下面是select
DataTable dt = new MySQLSelectCommand(conn,
new string[] {"SettingID","SettingValue"},
new string[] {"mysqldrivercs_test"},
new object[,] {{"SettingID","=",SettingID}},
null,
null
).Table;
string storedValue = dt.Rows[0]["SettingValue"].ToString();
下面是delete
new MySQLDeleteCommand(conn,"mysqldrivercs_test",new object[,] {{"SettingID","=",SettingID}},null);
关闭链接:
conn.Close();
相关文档:
windows2003----开始----运行---mysql -uroot -p,进入MYSQL数据库,输入密码,登陆。
show databases;看看有哪些数据库
use xxxxxx;(xxxxxx为数据库名,进入数据库)
update user set passwd=MD5('111111*') where user_name = 'admin';(111111为要修改的密码) ......
参见官方参考,第25章:API和库
25.2.3.49. mysql_ping()
int
mysql_ping(MYSQL *mysql)
描述
检查与服务器的连接是否工作。如果连接丢失,将自动尝试再连接。
该函数可被闲置了较长时间的客户端使用,用以检查服务器是否已关闭了连接,并在必要时再次连接。
返回值
如果与服务器的连接有效返回 ......
环境:两台服务器IP:192.168.30.57\192.168.30.58
1、下载mysql-5.0.86-linux-i686-glibc23.tar.gz 到http://dev.mysql.com/downloads/mysql/5.0.html#linux下载
2、解压 tar -zxvf
mysql-5.0.86-linux-i686-glibc23.tar.gz
3、创建链接 ln -s
mysql-5.0.86-linux-i686-g ......
1、在linux下:
查看mysql 是否运行:ps -ef | grep myslq
如果 MySQL 正在运行,首先杀之: kill mysql的进程号。
启动 MySQL :/usr/bin/safe_mysqld --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
>use mysql
......
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySQLDriverCS;
&nb ......