110,534
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
namespace trial1
{
class DBConnection
{
public static MySqlConnection getSqlCon()
{
string mysqlStr = "Database=weather;Data Source=127.0.0.1;UserID=otwo;Password=123456;pooling=false;CharSet=UTF8;port=3306";
MySqlConnection mysql = new MySqlConnection(mysqlStr);
return mysql;
}
public static MySqlCommand getSqlCommand(string sql, MySqlConnection mysql)
{
MySqlCommand sqlcommand = new MySqlCommand(sql, mysql);
return sqlcommand;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
using MySql.Data.MySqlClient;
namespace trial1
{
class Program
{
static void Main(string[] args)
{
MySqlConnection mysql = DBConnection.getSqlCon();
mysql.Open();
mysql.Close();