110,538
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
namespace mysqltest1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string strConn = "server=localhost;User Id=root;password=;Database=cshape;Charset=utf8";
MySqlConnection conn = new MySqlConnection(strConn);
conn.Open();//链接数据库
DataSet ds = new DataSet();
string sql = "select * from list_class1_submit";
MySqlDataAdapter da = new MySqlDataAdapter(sql, conn);
da.Fill(ds, "table");
dataGridView1.DataSource = ds.Tables["table"];
}
}
}