zoukankan      html  css  js  c++  java
  • vs2015 连接mysql

    //添加MySql.Data.dll 引用

    using
    MySql.Data.MySqlClient; using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private static String mysqlcon = "Database=yundaclient;Password=abc@123456;User ID=root;server=127.0.0.1;charset=utf8"; private MySqlConnection conn; private MySqlDataAdapter mDataAdapter; public Form1() { String sname = "Hello,Yummy!"; InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.button1.Click += new System.EventHandler(this.ShowMessage); conn = new MySqlConnection(mysqlcon); } private void ShowMessage(object sender, EventArgs e) { MessageBox.Show("Hello,world!"); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Hello,world123456789!"); } private void button2_Click(object sender, EventArgs e) { try { conn = new MySqlConnection(mysqlcon); mDataAdapter = new MySqlDataAdapter("select * from admin", conn); mDataAdapter.Fill(dataSet1, "Yummy"); dataGridView1.DataSource = dataSet1.Tables["Yummy"]; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } } private void chart1_Click(object sender, EventArgs e) { } } }
  • 相关阅读:
    bzoj 1406 数论
    bzoj 1927 网络流
    【HNOI】 攻城略池 tree-dp
    【HNOI】五彩斑斓 模拟
    linux下nano命令大全
    CentOS7.6下安装MySQL
    CentOS7.6下安装Oracle JDK
    Vue报错type check failed for prop
    图像分割
    提升方法(boosting)详解
  • 原文地址:https://www.cnblogs.com/yangxuming/p/8435457.html
Copyright © 2011-2022 走看看