ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[­ì³Ð] My SQL ¤¤¤å¶Ã½X¸Ñ¨M¤è¦¡

[­ì³Ð] My SQL ¤¤¤å¶Ã½X¸Ñ¨M¤è¦¡

¥»©«³Ì«á¥Ñ Min ©ó 2010-5-1 23:53 ½s¿è

1.SQL SERVER³]©w

my.ini (mysqld-nt)³]©w¤U
  1. #This File was made using the WinMySQLAdmin 1.4 Tool
  2. #2006/9/6 ¤U¤È 02:00:49

  3. #Uncomment or Add only the keys that you know how works.
  4. #Read the MySQL Manual for instructions

  5. [mysqld]
  6. basedir=C:/mysql
  7. #bind-address=10.10.10.10
  8. datadir=C:/mysql/data
  9. #language=C:/mysql/share/your language directory
  10. #slow query log#=
  11. #tmpdir#=
  12. #port=3306
  13. #set-variable=key_buffer=512M
  14. [color=Red]default-character-set=big5
  15. [WinMySQLadmin]
  16. Server=C:/mysql/bin/mysqld-nt.exe
  17. user=root
  18. password=baby
  19. [color=Red]default-character-set=big5

  20. [client]
  21. default-character-set=big5
  22. init_connect='SET NAMES big5'
½Æ»s¥N½X
2.ADO³s½u³]©w
  1. Cnnl.Open "Driver={MySQL ODBC 3.51 Driver};Server=SERVER_NAME;Port=3306;Database=test;CharSet=big5;Uid=root;Pwd=;Option=16387"
½Æ»s¥N½X
(¬õ¦â¦r ¬O»Ý·s¼Wªº!)

´N¬O§â
default-character-set§ï¦¨big5
default-character-set=big5
¬O§a!
thanks

TOP

¦^´_ 1# Min
·PÁ±z´£¨Ñªº½d¨Ò¡A³Ìªñ¦bWinXP¤W¦w¸ËmySQL5.6¡A¹w³]ªºmy.ini´N¥u¦³¨â¦æ¡G
--------------
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
----------------
«ôŪ±zªº¤å³¹¡A¤~ª¾¹D¦³¤¤¤å¶Ã½Xªº°ÝÃD¤Î¸Ñ¨Mªº³]©w¡C
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¤£½×¬O³]¦¨big5
  1. [mysqld]
  2. default-character-set=big5

  3. [WinMySQLadmin]
  4. default-character-set=big5

  5. [client]
  6. default-character-set=big5
½Æ»s¥N½X
©Î¬O³]¦¨utf8
  1. [mysqld]
  2. default-character-set=utf8

  3. [WinMySQLadmin]
  4. default-character-set=utf8

  5. [client]
  6. default-character-set=utf8
½Æ»s¥N½X
µ²ªG³£¬O¤@¼Ë¡A¤¤¤å³£¬O¶Ã½X¡C
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦^´_ 4# heavenweaver
¤Wºô§ä­Ó AutoItªºMySQL UDFs¡A´ú¸Õutf8¤Îbig5¡Aµ²ªG¬O¥Îbig5¤~¥i¥H¥¿½TÅã¥Ü¡C
´ú¸Õµ{¦¡¦p¤U¡G
  1. #include "mysql.au3"
  2. #include <Array.au3>

  3. ;===================================================================================
  4. ; This is a demo script that show you how to use MySQL UDFs with AutoIT
  5. ; Script:   MySQL UDFs working with libmysql.dll
  6. ; Version:  1.0.0.2
  7. ; Author:   Prog@ndy
  8. ;
  9. ; You can dowload MySQL UDFs from this URL
  10. ; http://progandy.de/downloads/summary/3-autoit-udfs/4-mysql-udfs.html
  11. ; Remarks by : Heavenweaver Lu
  12. ;===================================================================================
  13. ; MYSQL Initiate
  14. _MySQL_InitLibrary()
  15. If @error Then Exit MsgBox(0, '', "Could not Initiate MySQL")
  16. Global $MysqlConn = _MySQL_Init()
  17. Local $res

  18. Database()
  19. ShowTableContent()

  20. ; Query releasing
  21. _MySQL_Free_Result($res)
  22. ; Ending a connection
  23. _MySQL_Close($MysqlConn)
  24. ; MYSQL Ending
  25. _MySQL_EndLibrary()


  26. Func DATABASE()
  27.         Local $strHost = "127.0.0.1", $strUID = "root", $strPass = "http://forum.twbts.com", $strDB = "test"
  28.         $connected = _MySQL_Real_Connect($MysqlConn,$strHost, $strUID ,$strPass,$strDB )
  29.         If $connected = 0 Then
  30.                 $errno = _MySQL_errno($MysqlConn)
  31.                 MsgBox(0, "Error:", $errno & @LF & _MySQL_error($MysqlConn))
  32.                 If $errno = $CR_UNKNOWN_HOST Then MsgBox(0, "Error:", "$CR_UNKNOWN_HOST" & @LF & $CR_UNKNOWN_HOST)
  33.                 _MySQL_Close($MysqlConn)
  34.                 _MySQL_EndLibrary()
  35.                 Exit
  36.         EndIf

  37.         _MySQL_Set_Character_Set($MysqlConn, "big5")
  38.         _MySQL_Real_Query($MysqlConn, "CREATE DATABASE IF NOT EXISTS test DEFAULT CHARSET big5")
  39.         _MySQL_Real_Query($MysqlConn, "use test;")

  40.         Local $timedate = "now()"
  41.         Local $my = "00:F0:00:FF:00:FF"
  42.         Local $Name = "testname"
  43.         Local $IDname = "s448920"
  44.         Local $User = "³Â»¶®a±Ú"
  45.         Local $code = "11111"
  46.         Local $alltest = "PASS"
  47.         Local $time1 = "232"
  48.         Local $time2 = "234"

  49.                 $sTable = "test"
  50.         $strSQLcmd = "DROP TABLE IF EXISTS " & $sTable & ";"
  51.                 _MySQL_Real_Query($MysqlConn, $strSQLcmd)
  52.         $sMySqlStatement = "CREATE TABLE IF NOT EXISTS test (" & _
  53.                         "TimeDate TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," & _
  54.                         "Name TEXT NOT NULL ," & _
  55.                         "My TEXT NOT NULL," & _
  56.                         "IDname TEXT NOT NULL ," & _
  57.                         "User TEXT NOT NULL ," & _
  58.                         "Code TEXT NOT NULL ," & _
  59.                         "Result TEXT NOT NULL ," & _
  60.                         "Time1 TEXT NOT NULL ," & _
  61.                         "Time2 TEXT NOT NULL );"

  62.         if _MySQL_Real_Query($MysqlConn, $sMySqlStatement,StringLen($sMySqlStatement) * 2) <> $MYSQL_SUCCESS Then
  63.                 ConsoleWrite("Error: " &  _MySQL_errno($MysqlConn) & " " & _MySQL_error($MysqlConn) & @LF)
  64.                 Return
  65.         EndIf

  66.         Local $sMySqlStatement = "INSERT INTO test (TimeDate, Name, My, IDname," & _
  67.                         "User,Code,Result,Time1,Time2) VALUES (NOW()," & _
  68.                         "'" & $my & "'," & _
  69.                         "'" & $Name & "'," & _
  70.                         "'" & $IDname & "'," & _
  71.                         "'" & $User & "'," & _
  72.                         "'" & $code & "'," & _
  73.                         "'" & $alltest & "'," & _
  74.                         "'" & $time1 & "'," & _
  75.                         "'" & $time2 & "');"

  76.     ConsoleWrite("$sMySqlStatement " & $sMySqlStatement & @LF)
  77.         If _MySQL_Real_Query($MysqlConn,$sMySqlStatement,StringLen($sMySqlStatement) * 2) <> $MYSQL_SUCCESS Then
  78.                 ConsoleWrite("error: " & _MySQL_errno($MysqlConn) & " " & _MySQL_error($MysqlConn) & @LF)
  79.                 MsgBox(16, "error: " & _MySQL_errno($MysqlConn), _MySQL_error($MysqlConn))
  80.                 Return
  81.         Else
  82.                                 ConsoleWrite("!mysql> Congradulation! Data Insert Compeleted" & @CRLF)
  83.         EndIf
  84.         EndFunc   ;==>DATABASE

  85. Func ShowTableContent()

  86. $query = "SELECT * FROM test"
  87. _MySQL_Real_Query($MysqlConn, $query)
  88. $res = _MySQL_Store_Result($MysqlConn)
  89. $fields = _MySQL_Num_Fields($res)
  90. $rows = _MySQL_Num_Rows($res)
  91. ;MsgBox(0, "", $rows & "-" & $fields)
  92. ConsoleWrite("!mysql> " & "Rows = " & $rows & " x " & "Columns = " & $fields & @CRLF)

  93. ; Access 1
  94. ;MsgBox(0, '', "Access Methode 1- manual work")
  95. Dim $array[$rows][$fields]
  96. For $k = 1 To $rows
  97.         $mysqlrow = _MySQL_Fetch_Row($res,$fields)
  98.         $lenthsStruct = _MySQL_Fetch_Lengths($res)
  99.         For $i = 1 To $fields
  100.                 $length = DllStructGetData($lenthsStruct, 1, $i)
  101.                 $fieldPtr = DllStructGetData($mysqlrow, 1, $i)
  102.                 $data = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1)
  103.                 $array[$k - 1][$i - 1] = $data
  104.         Next
  105. Next
  106. _ArrayDisplay($array)

  107. ; Access 2
  108. ;MsgBox(0, '', "Access Methode 2 - Series")
  109. _MySQL_Data_Seek($res, 0) ; only for to the beginning of the query
  110. Do
  111. $row1 = _MySQL_Fetch_Row_StringArray($res)
  112. If @error Then ExitLoop
  113. _ArrayDisplay($row1)
  114. Until @error

  115. ;MsgBox(0, '', "Access Method 3 - all in a 2D array")
  116. $array = _MySQL_Fetch_Result_StringArray($res)
  117. _ArrayDisplay($array)

  118. ; Field information
  119. ;MsgBox(0, '', "Field information")

  120. Dim $arFields[$fields][3]
  121. For $i = 0 To $fields - 1
  122.         $field = _MySQL_Fetch_Field_Direct($res, $i)
  123.         $arFields[$i][0] = _MySQL_Field_ReadValue($field, "name")
  124.         $arFields[$i][1] = _MySQL_Field_ReadValue($field, "table")
  125.         $arFields[$i][2] = _MySQL_Field_ReadValue($field, "db")
  126. Next
  127. _ArrayDisplay($arFields)
  128. EndFunc   ;==>ShowTableContent
½Æ»s¥N½X
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦^´_ 5# heavenweaver
¦³¹Ï¦³¯u¬Û¡I

20140226-40.jpg
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

AutoItªºEzMySql.au3 UDFs¡A¤£¥Î³]©wutf8©Îbig5¡A¤¤¤å¥i¥H¥¿½TÅã¥Ü¡C
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

        ÀR«ä¦Û¦b : ¦³¦h¤Ö¤O¶q´N°µ¦h¤Ö¨Æ¡A¤£­n¤ß¦sµ¥«Ý¡Aµ¥«Ý¤~·|¸¨ªÅ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD