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"]);
                }          
               
            }

  • 相关阅读:
    [译]CasperJS,基于PhantomJS的工具包
    [译]JavaScript:typeof的用途
    [译]JavaScript写的一个quine程序
    [译]Ruby中的解构赋值
    [译]DOM:元素ID就是全局变量
    [译]ECMAScript 6中的集合类型,第一部分:Set
    [译]JavaScript:Array.prototype和[]的性能差异
    [译]Web Inspector开始支持CSS区域
    [译]JavaScript:反科里化"this"
    [译]JavaScript:用什么来缩进
  • 原文地址:https://www.cnblogs.com/xkis/p/3072992.html
Copyright © 2011-2022 走看看