Fork me on GitHub

网络游戏_数据库查询

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;

namespace MySql数据库操作
{
    class Program
    {
        static void Main(string[] args)
        {
            string connStr = "Database=game;Data Source=127.0.0.1;port=3306;User Id=root;Password=shirln123My;";
            MySqlConnection conn = new MySqlConnection(connStr);
            conn.Open();

            #region 查询
            // MySqlCommand cmd = new MySqlCommand("select * from user where id=1", conn);
            // MySqlDataReader reader = cmd.ExecuteReader();
            //while(reader.Read())
            // {              
            //     string username = reader.GetString("username");
            //     string password = reader.GetString("password");
            //     Console.WriteLine(username+";"+password);

            // }
            // reader.Close();
            #endregion  

            conn.Close();
            Console.ReadKey();
        }
    }
}

posted @ 2017-11-21 17:39  爱上游戏开发  阅读(418)  评论(0编辑  收藏  举报
 >>>转载请注明出处