C#加mysql
来源:互联网 发布:淘宝小石头运动添柏岚 编辑:程序博客网 时间:2024/06/05 04:17
在网上看了很多都是把所有数据拿回来,设置个数据桥,就在数据view展示了。 哎,想要个和Navicat一样的,能写语句的啊!
直接贴!
// 获得数据库名称
string KuName = textBox1.Text.ToString();
//获取语句
string sql = richTextBox1.Text;
//读链接
string myconn = string.Empty;
if (comboBox1.Text == "读链接")
{
myconn = *****
}
else
{
myconn = s****
}
//写链接
conn = new MySqlConnection(myconn);
//存储文件位置
string path = string.Format(@"F:\{0}{1}.txt", KuName, DateTime.Now.ToString("yyyyMMddHHmmss"));
FileStream fs1 = new FileStream(path, FileMode.Append, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
try
{
//打开连接
conn.Open();
// 设置数据桥
dataAdapter = new MySqlDataAdapter("USE " + KuName +";\r\n"+ sql, conn);
// DataSet
sqlCmdBuilder = new MySqlCommandBuilder(dataAdapter);
// 数据
DataSet ds = new DataSet().;
string[] arr = new string[9999999];
int n = 0;
foreach (DataRow dr in ds.Tables[0].Rows)
{
for (int i = 0; i < dr.ItemArray.Length; i++)
{
arr[n] += dr.ItemArray[i].ToString() + " ";
}
n = n + 1;
}
for (int i = 0; i < arr.Length; i++)
{
sw.WriteLine(arr[i]);
sw.Flush();
}
sw.Close();
fs1.Close();
}
catch (Exception ex)
{
sw.WriteLine(ex.ToString());
sw.Flush();
sw.Close();
fs1.Close();
}
finally
{
conn.Close();
}
- C#加mysql
- word 加水印C#
- C# 图片加水印
- C#加解密
- C# 简单加壳
- C# 图片加水印
- C# 自定义加壳
- C# MD5加解密
- C#反射加壳
- C#加解密
- C#文件加解密
- c# md5 加解密
- C# 加水印效果
- 图片加水印c#
- C# 对称加解密
- c# AES加解密
- C#加水印~
- c#数据加解密
- 35. Search Insert Position
- listview中点击item进行Item中的控件更新操作
- pycharm 快捷键
- Android中自定义MultipartEntity实现文件上传以及使用Volley库实现文件上传
- 解决Android Studio open an existing project 时找不到想打开项目的问题
- C#加mysql
- weblogic部署的web应用,打开报错Error 403--Forbidden
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】
- C# dataGridView限制某一行的单元格只输入数字的方法之一
- JS之function
- PHP语言构造器介绍
- spring boot整合mybatis
- 访问127.0.0.1出错或者显示的不是想要的信息
- 判断String对象相等