C#连接数据库
来源:互联网 发布:mac虚拟机安装win7不了 编辑:程序博客网 时间:2024/06/05 07:41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySQLDriverCS;
using System.Windows.Forms;
namespace 清洁生产报告辅助软件
{
class Mysql
{
public string[] str1;
public string[] str5;
public Mysql(string str)
{
//得到文本框内容进行检索
MySQLConnection conn = null;
conn = new MySQLConnection(new MySQLConnectionString("localhost", "test", "root", "cao564335").AsString);
conn.Open();
String sqlInsert1 = "SELECT COUNT(new1) FROM t_table3";
// String sqlInsert = "insert into t_table3 values ('1','25','E:\\\\\\\\保存的文件\\\\\\\\3.txt')";
MySQLCommand commn2 = new MySQLCommand(sqlInsert1, conn);
commn2.ExecuteScalar();
string str2 = commn2.ExecuteScalar().ToString();
int v1 = Convert.ToInt32(str2);
this.str1 = new string[v1];
this.str5 = new string[v1];
MySQLCommand commn = new MySQLCommand("set names gb2312", conn);
commn.ExecuteNonQuery();
string sd = "select new3,new2 from t_table3 where new3 like'" + "%" + str + "%'";//进行查找
MySQLCommand cmd = new MySQLCommand(sd, conn);//
MySQLDataReader dr = cmd.ExecuteReaderEx();
int i = 0;
while (dr.Read())
{
this.str1[i] = dr[0].ToString();
this.str5[i] = dr[1].ToString();
i++;
}
// MessageBox.Show("第一个界面" + str5[0]);
// MessageBox.Show("第er个界面" + str1[0]);
dr.Close();
conn.Close();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySQLDriverCS;
using System.Windows.Forms;
namespace 清洁生产报告辅助软件
{
class Mysql
{
public string[] str1;
public string[] str5;
public Mysql(string str)
{
//得到文本框内容进行检索
MySQLConnection conn = null;
conn = new MySQLConnection(new MySQLConnectionString("localhost", "test", "root", "cao564335").AsString);
conn.Open();
String sqlInsert1 = "SELECT COUNT(new1) FROM t_table3";
// String sqlInsert = "insert into t_table3 values ('1','25','E:\\\\\\\\保存的文件\\\\\\\\3.txt')";
MySQLCommand commn2 = new MySQLCommand(sqlInsert1, conn);
commn2.ExecuteScalar();
string str2 = commn2.ExecuteScalar().ToString();
int v1 = Convert.ToInt32(str2);
this.str1 = new string[v1];
this.str5 = new string[v1];
MySQLCommand commn = new MySQLCommand("set names gb2312", conn);
commn.ExecuteNonQuery();
string sd = "select new3,new2 from t_table3 where new3 like'" + "%" + str + "%'";//进行查找
MySQLCommand cmd = new MySQLCommand(sd, conn);//
MySQLDataReader dr = cmd.ExecuteReaderEx();
int i = 0;
while (dr.Read())
{
this.str1[i] = dr[0].ToString();
this.str5[i] = dr[1].ToString();
i++;
}
// MessageBox.Show("第一个界面" + str5[0]);
// MessageBox.Show("第er个界面" + str1[0]);
dr.Close();
conn.Close();
}
}
}
- C#连接数据库 SqlCommand
- C#连接Access数据库
- C#连接各类数据库
- C#连接Oracle数据库
- c#连接sql数据库
- c#连接sql数据库:
- C#连接数据库集锦
- c#连接数据库大全
- C#连接Acess数据库
- C# 连接数据库程序代码
- C#连接oracle数据库
- c#连接数据库大全
- C#连接access数据库
- c#连接数据库锦
- c#连接各种数据库
- c#连接各类数据库
- c#连接各类数据库
- C#连接SQL数据库
- JAVA实现DES加密
- 《高可用MySQL——构建健壮的数据中心》读书笔记之一
- TYPES和DATA的区别
- ACE线程之ACE_Thread_Mutex互斥锁
- Linux经验笔记
- C#连接数据库
- 追逐的日子
- linux系统下将php和mysql命令加入到环境变量中的方法
- [转]用友NC单据UI基本代码示例
- Github Mybatis深入学习之Java API
- ARM中的RO、RW和ZI DATA
- MFC中菜单相关
- struts 2.1.6 StrutsPrepareAndExecuteFilter学习笔记
- 确认网站关键词的标准-摘自百度百科-长尾关键词