zoukankan      html  css  js  c++  java
  • C# 连mysql

     static void Main(string[] args)
            {
                string sqlstr = "select * from manavatar";
                MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString("192.168.0.13", "flashdata", "root", "root", 3306).AsString);
                DBConn.Open();
                //MySQLDataAdapter myadap = new MySQLDataAdapter(sqlstr, conn);
                MySQLCommand DBComm = new MySQLCommand(sqlstr,DBConn);
                MySQLDataReader DBReader = DBComm.ExecuteReaderEx(); //DBComm.ExecuteReaderEx();
                MySQLDataAdapter DTAdapter = new MySQLDataAdapter(sqlstr,DBConn);
               
                DataSet myDataSet = new DataSet();
                DTAdapter.Fill(myDataSet,"manavatar");
             
            
                try
                {
                    while (DBReader.Read())
                    {
                        //Console.WriteLine("11");
                        Console.WriteLine("DBReader:{0},\t\t\tddddd:{1},\t\t {2}",DBReader.GetString(0), DBReader.GetString(1),DBReader.GetString(3));
                    }
                    Console.WriteLine("0000");
                }
                catch (Exception e)
                {
                    Console.WriteLine("读入失败!"+e.ToString());
                }
                finally
                {
                    Console.WriteLine("DBReader关闭");
                    Console.WriteLine("DBConn关闭");
                    DBReader.Close();
                    //DBConn.Close();
                }
               
                for (int i = 0; i < myDataSet.Tables["manavatar"].Rows.Count; i++)
                {
                    Console.WriteLine("{0}",myDataSet.Tables["manavatar"].Rows[2]["user"]);
                }          
               
            }

  • 相关阅读:
    ADB 操作手机的粘贴板
    JSESSIONID的简单说明
    Android无线调试出现错误的解决方法
    adb shell input text 完美支持中文输入
    SQL Server 2022来了
    新技能GET!在前端表格中花式使用异步函数的奥义
    地表最强IDE ——Visual Studio 2022正式发布
    用前端表格技术构建医疗SaaS 解决方案
    JavaScript Sanitizer API:原生WEB安全API出现啦
    突破技术限制,实现Web端静默打印
  • 原文地址:https://www.cnblogs.com/xkis/p/3072992.html
Copyright © 2011-2022 走看看