在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();
相关文档:
在主外键表存在关系的时候如果加上"lazy=true"的话,则表明延迟,即只查询主表中的内容,而不查询外键表中的内容。
例:
<hibernate-mapping>
<class name="com.pojo.Sortp" table="sortp" catalog="shjdc">
<id name="id" type= ......
1、登陆MySQL:
mysql -u root -p
2、查看用户信息
select user,host,password from mysql.user;
select user,host from mysql.user;
3、设置密码
set password for root@localhost=password('
在这里填入root密码
');
4、修改密码
方法1:mysqladmin -u root -p password newpassword
方法2: #mysql -u root ......
1、在linux下:
查看mysql 是否运行:ps -ef | grep myslq
如果 MySQL 正在运行,首先杀之: kill mysql的进程号。
启动 MySQL :/usr/bin/safe_mysqld --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
>use mysql
......
解决乱码最好的方法是在项目设计之初,统一所有的字符集,例如页面、request对象以及数据库等等。
一、 几种常见的乱码现象:
1、页面乱码
单纯的页面乱码是很好解决的,只要修改头部适合的字符集即可,如果页面中文显示乱码,你可以把字符集修改为:gb2312或gbk。
2、页面之间传递的参数是乱码 ......
#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "123"
#define database "oa"
MYSQL *conn;
int main()
{
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i,ret;
FILE *fp;
MYSQL_FIELD *field;
......