📄 m_mysql.bas
字号:
Attribute VB_Name = "m_MySQL"
'################################################################################'
'# VBMySQL APi version .01 #
'# Copyright (C) 2000 Jim Banasiak <itsjimbo@yahoo.com> #
'# #
'# This program is free software; you can redistribute it and/or #
'# modify it under the terms of the GNU General Public License #
'# as published by the Free Software Foundation; either version 2 #
'# of the License, or (at your option) any later version. #
'# #
'# This program is distributed in the hope that it will be useful, #
'# but WITHOUT ANY WARRANTY; without even the implied warranty of #
'# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
'# GNU General Public License for more details. #
'# #
'# You should have received a copy of the GNU General Public License #
'# along with this program; if not, write to the Free Software #
'# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
'# #
'################################################################################
'/****************************************************************************/'
'Translation of API function calls to libmysql.dll (export list)
'Tested on VB6
'/****************************************************************************/'
Option Explicit
Public Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)
'/****************************************************************************/'
Public Declare Function API_mysql_num_rows Lib "libmysql.dll" Alias "mysql_num_rows" (result As API_MYSQL_RES) As API_myulonglong 'don't forget to convert64
Public Declare Function API_mysql_num_fields Lib "libmysql.dll" Alias "mysql_num_fields" (result As API_MYSQL_RES) As Long
Public Declare Function API_mysql_eof Lib "libmysql.dll" Alias "mysql_eof" (result As API_MYSQL_RES) As Byte
Public Declare Function API_mysql_fetch_field_direct Lib "libmysql.dll" Alias "mysql_fetch_field_direct" (result As API_MYSQL_RES, fieldnr As Long) As Long
'/****************************************************************************/'
Public Declare Function API_mysql_fetch_fields Lib "libmysql.dll" Alias "mysql_fetch_fields" (result As API_MYSQL_RES) As Long
Public Declare Function API_mysql_row_tell Lib "libmysql.dll" Alias "mysql_row_tell" (result As API_MYSQL_RES) As Long
Public Declare Function API_mysql_field_tell Lib "libmysql.dll" Alias "mysql_field_tell" (result As API_MYSQL_RES) As Long
'/****************************************************************************/'
Public Declare Function API_mysql_field_count Lib "libmysql.dll" Alias "mysql_field_count" (TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_affected_rows Lib "libmysql.dll" Alias "mysql_affected_rows" (TMYSQL As API_MYSQL) As API_myulonglong 'don't forget to convert64
Public Declare Function API_mysql_insert_id Lib "libmysql.dll" Alias "mysql_insert_id" (TMYSQL As API_MYSQL) As API_myulonglong 'again..don't forget convert64
Public Declare Function API_mysql_errno Lib "libmysql.dll" Alias "mysql_errno" (TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_error Lib "libmysql.dll" Alias "mysql_error" (TMYSQL As API_MYSQL) As Long 'pointer to char *
'/****************************************************************************/'
Public Declare Function API_mysql_info Lib "libmysql.dll" Alias "mysql_info" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_thread_id Lib "libmysql.dll" Alias "mysql_thread_id" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_init Lib "libmysql.dll" Alias "mysql_init" (ByRef TMYSQL As API_MYSQL) As Long
'/****************************************************************************/'
Public Declare Function API_mysql_connect Lib "libmysql.dll" Alias "mysql_connect" (ByRef TMYSQL As API_MYSQL, ByVal host As Long, ByVal user As Long, ByVal Passwd As Long) As Long
Public Declare Function API_mysql_real_connect Lib "libmysql.dll" Alias "mysql_real_connect" (ByRef TMYSQL As API_MYSQL, ByVal host As Long, ByVal user As Long, ByVal Passwd As Long, ByVal DB As Long, ByVal Port As Long, ByVal Unix_Socket As Long, ByVal clientflag As Long) As Long
Public Declare Function API_mysql_close Lib "libmysql.dll" Alias "mysql_close" (TMYSQL As API_MYSQL) As Long
'/****************************************************************************/'
Public Declare Function API_mysql_select_db Lib "libmysql.dll" Alias "mysql_select_db" (ByRef TMYSQL As API_MYSQL, ByVal DB As Long) As Long
Public Declare Function API_mysql_query Lib "libmysql.dll" Alias "mysql_query" (ByRef TMYSQL As API_MYSQL, ByVal q As Long) As Long
Public Declare Function API_mysql_real_query Lib "libmysql.dll" Alias "mysql_real_query" (ByRef TMYSQL As API_MYSQL, ByVal q As Long, ByVal length As Long) As Long
Public Declare Function API_mysql_create_db Lib "libmysql.dll" Alias "mysql_create_db" (ByRef TMYSQL As API_MYSQL, ByVal DB As Long) As Long
Public Declare Function API_mysql_drop_db Lib "libmysql.dll" Alias "mysql_drop_db" (ByRef TMYSQL As API_MYSQL, ByVal DB As Long) As Long
Public Declare Function API_mysql_shutdown Lib "libmysql.dll" Alias "mysql_shutdown" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_dump_debug_info Lib "libmysql.dll" Alias "mysql_dump_debug_info" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_refresh Lib "libmysql.dll" Alias "mysql_refresh" (ByRef TMYSQL As API_MYSQL, ByVal refresh_options As Long) As Long
Public Declare Function API_mysql_kill Lib "libmysql.dll" Alias "mysql_kill" (ByRef TMYSQL As API_MYSQL, ByVal PID As Long) As Long
Public Declare Function API_mysql_ping Lib "libmysql.dll" Alias "mysql_ping" (ByRef TMYSQL As API_MYSQL) As Long
'/****************************************************************************/'
Public Declare Function API_mysql_stat Lib "libmysql.dll" Alias "mysql_stat" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_get_server_info Lib "libmysql.dll" Alias "mysql_get_server_info" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_get_client_info Lib "libmysql.dll" Alias "mysql_get_client_info" () As Long
Public Declare Function API_mysql_get_host_info Lib "libmysql.dll" Alias "mysql_get_host_info" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_get_proto_info Lib "libmysql.dll" Alias "mysql_get_proto_info" (ByRef TMYSQL As API_MYSQL) As Long
'/****************************************************************************/'
Public Declare Function API_mysql_list_dbs Lib "libmysql.dll" Alias "mysql_list_dbs" (ByRef TMYSQL As API_MYSQL, ByVal wild As Long) As Long
Public Declare Function API_mysql_list_tables Lib "libmysql.dll" Alias "mysql_list_tables" (ByRef TMYSQL As API_MYSQL, ByVal wild As Long) As Long
Public Declare Function API_mysql_list_fields Lib "libmysql.dll" Alias "mysql_list_fields" (ByRef TMYSQL As API_MYSQL, ByVal table As Long, ByVal wild As Long) As Long
Public Declare Function API_mysql_list_processes Lib "libmysql.dll" Alias "mysql_list_processes" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_store_result Lib "libmysql.dll" Alias "mysql_store_result" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_use_result Lib "libmysql.dll" Alias "mysql_use_result" (ByRef TMYSQL As API_MYSQL) As Long
Public Declare Function API_mysql_options Lib "libmysql.dll" Alias "mysql_options" (ByRef TMYSQL As API_MYSQL, TMYSQL_OPTION As API_mysql_option, ByVal arg As Long) As Long
Public Declare Function API_mysql_free_result Lib "libmysql.dll" Alias "mysql_free_result" (ByRef result As API_MYSQL_RES) As Long
Public Declare Function API_mysql_data_seek Lib "libmysql.dll" Alias "mysql_data_seek" (ByRef result As API_MYSQL_RES, ByVal offset As Double) As Long 'need byval 8 bytes
Public Declare Function API_mysql_row_seek Lib "libmysql.dll" Alias "mysql_row_seek" (ByRef result As API_MYSQL_RES, ByVal MYSQL_ROW_OFFSET As Long) As Long
Public Declare Function API_mysql_field_seek Lib "libmysql.dll" Alias "mysql_field_seek" (ByRef result As API_MYSQL_RES, offset)
Public Declare Function API_mysql_fetch_row Lib "libmysql.dll" Alias "mysql_fetch_row" (ByRef result As API_MYSQL_RES) As Long 'pointer to array
Public Declare Function API_mysql_fetch_lengths Lib "libmysql.dll" Alias "mysql_fetch_lengths" (result As API_MYSQL_RES) As Long 'returns * unsigned long
Public Declare Function API_mysql_fetch_field Lib "libmysql.dll" Alias "mysql_fetch_field" (result As API_MYSQL_RES) As Long
Public Declare Function API_mysql_escape_string Lib "libmysql.dll" Alias "mysql_escape_string" (ByRef TMYSQL As API_MYSQL, ByVal to_ As Long, ByVal from_ As Long, ByVal length As Long) As Long
Public Declare Function API_mysql_debug Lib "libmysql.dll" Alias "mysql_debug" (ByVal debug_ As Long) As Long
Public Declare Function API_mysql_thread_safe Lib "libmysql.dll" Alias "mysql_thread_safe" () As Long
'Public Declare Function API_mysql_character_set_name Lib "libmysql.dll" Alias "mysql_character_set_name" (ByRef TMYSQL As API_MYSQL) As Long
'Public Declare Function API_mysql_change_user Lib "libmysql.dll" Alias "mysql_change_user" (ByRef TMYSQL As API_MYSQL, ByVal user As Long) As Byte
'#################### TAKEN MYSQL.COM (description of API functions) ########################################
'mysql_affected_rows() Returns the number of rows affected by the last UPDATE, DELETE, or INSERT query.
'mysql_close() Closes a server connection.
'mysql_connect() Connects to a MySQL server. This function is deprecated; use mysql_real_connect() instead.
'mysql_change_user() Changes user and database on an open connection.
'mysql_character_set_name() Returns the name of the default character set for the connection.
'mysql_create_db() Creates a database. This function is deprecated; use the SQL command CREATE DATABASE instead.
'mysql_data_seek() Seeks to an arbitrary row in a query result set.
'mysql_debug() Does a DBUG_PUSH with the given string.
'mysql_drop_db() Drops a database. This function is deprecated; use the SQL command DROP DATABASE instead.
'mysql_dump_debug_info() Makes the server write debug information to the log.
'mysql_eof() Determines whether or not the last row of a result set has been read. This function is deprecated; mysql_errno() or mysql_error() may be used instead.
'mysql_errno() Returns the error number for the most recently invoked MySQL function.
'mysql_error() Returns the error message for the most recently invoked MySQL function.
'mysql_real_escape_string() Escapes special characters in a string for use in a SQL statement taking into account the current charset of the connection.
'mysql_escape_string() Escapes special characters in a string for use in a SQL statement.
'mysql_fetch_field() Returns the type of the next table field.
'mysql_fetch_field_direct() Returns the type of a table field, given a field number.
'mysql_fetch_fields() Returns an array of all field structures.
'mysql_fetch_lengths() Returns the lengths of all columns in the current row.
'mysql_fetch_row() Fetches the next row from the result set.
'mysql_field_seek() Puts the column cursor on a specified column.
'mysql_field_count() Returns the number of result columns for the most recent query.
'mysql_field_tell() Returns the position of the field cursor used for the last mysql_fetch_field().
'mysql_free_result() Frees memory used by a result set.
'mysql_get_client_info() Returns client version information.
'mysql_get_host_info() Returns a string describing the connection.
'mysql_get_proto_info() Returns the protocol version used by the connection.
'mysql_get_server_info() Returns the server version number.
'mysql_info() Returns information about the most recently executed query.
'mysql_init() Gets or initializes a MYSQL structure.
'mysql_insert_id() Returns the ID generated for an AUTO_INCREMENT column by the previous query.
'mysql_kill() Kills a given thread.
'mysql_list_dbs() Returns database names matching a simple regular expression.
'mysql_list_fields() Returns field names matching a simple regular expression.
'mysql_list_processes() Returns a list of the current server threads.
'mysql_list_tables() Returns table names matching a simple regular expression.
'mysql_num_fields() Returns the number of columns in a result set.
'mysql_num_rows() Returns the number of rows in a result set.
'mysql_options() Sets connect options for mysql_connect().
'mysql_ping() Checks whether or not the connection to the server is working, reconnecting as necessary.
'mysql_query() Executes a SQL query specified as a null-terminated string.
'mysql_real_connect() Connects to a MySQL server.
'mysql_real_query() Executes a SQL query specified as a counted string.
'mysql_reload() Tells the server to reload the grant tables.
'mysql_row_seek() Seeks to a row in a result set, using value returned from mysql_row_tell().
'mysql_row_tell() Returns the row cursor position.
'mysql_select_db() Selects a database.
'mysql_shutdown() Shuts down the database server.
'mysql_stat() Returns the server status as a string.
'mysql_store_result() Retrieves a complete result set to the client.
'mysql_thread_id() Returns the current thread ID.
'mysql_thread_save() Returns 1 if the clients are compiled as threadsafe.
'mysql_use_result() Initiates a row-by-row result set retrieval.
'/****************************************************************************/'
'/* NOT EXPORTED BY DLL --
'/* If they are i need to look at the libmysql.dll again
'/****************************************************************************/'
'Public Declare Function API_mysql_real_escape_string Lib "libmysql.dll" Alias "mysql_real_escape_string" ()
'Public Declare Function API_mysql_ssl_set Lib "libmysql.dll" Alias "mysql_ssl_set" (ByRef TMYSQL As API_MYSQL, ByVal key As Long, ByVal cert As Long, ByVal ca As Long, ByVal capath As Long) As Long
'Public Declare Function API_mysql_ssl_cipher Lib "libmysql.dll" Alias "mysql_ssl_cipher" (ByRef TMYSQL As API_MYSQL) As Long
'Public Declare Function API_mysql_ssl_clear Lib "libmysql.dll" Alias "mysql_ssl_clear" (ByRef TMYSQL As API_MYSQL) As Long
'Public Declare Function API_mysql_odbc_escape_string Lib "libmysql.dll" Alias "mysql_odbc_escape_string" (ByRef TMYSQL As API_MYSQL, ByVal to_ As Long, ByVal to_length As Long, ByVal from_ As Long, ByVal from_length As Long,param as Any,byval extended_buffer as Long)
'Public Declare Function API_myodbc_remove_escape_string Lib "libmysql.dll" Alias "myodbc_remove_escape" (ByRef TMYSQL As API_MYSQL, ByVal name As Long) As Long
'/****************************************************************************/'
'----------------------------------------------------
'translated from mysql_com.h
'----------------------------------------------------
Public Const SIZE_OF_CHAR = 4
Public Const NAME_LEN = 64
Public Const HOSTNAME_LENGTH = 60
Public Const USERNAME_LENGTH = 16
Public Const LOCAL_HOST = "localhost"
Public Const LOCAL_HOST_NAMEDPIPE = "MySQL"
Public Const MYSQL_SERVICENAME = "MySql"
Public Enum enum_server_command
COM_SLEEP
COM_QUIT
COM_INIT_DB
COM_QUERY
COM_FIELD_LIST
COM_CREATE_DB
COM_DROP_DB
COM_REFRESH
COM_SHUTDOWN
COM_STATISTICS
COM_PROCESS_INFO
COM_CONNECT
COM_PROCESS_KILL
COM_DEBUG
COM_PING
COM_TIME
COM_DELAYED_INSERT
End Enum
Public Const NOT_NULL_FLAG = 1
Public Const PRI_KEY_FLAG = 2
Public Const UNIQUE_KEY_FLAG = 4
Public Const MULTIPLE_KEY_FLAG = 8
Public Const BLOB_FLAG = 16
Public Const UNSIGNED_FLAG = 32
Public Const ZEROFILL_FLAG = 64
Public Const BINARY_FLAG = 128
Public Const ENUM_FLAG = 256
Public Const AUTO_INCREMENT_FLAG = 512
Public Const TIMESTAMP_FLAG = 1024
Public Const SET_FLAG = 2048
Public Const PART_KEY_FLAG = 16384
Public Const GROUP_FLAG = 32768
Public Const UNIQUE_FLAG = 65536
Public Const REFRESH_GRANT = 1
Public Const REFRESH_LOG = 2
Public Const REFRESH_TABLES = 4
Public Const REFRESH_HOSTS = 8
Public Const REFRESH_STATUS = 16
Public Const REFRESH_THREADS = 32
Public Const REFRESH_SLAVE = 64
Public Const REFRESH_MASTER = 128
Public Const REFRESH_READ_LOCK = 256
Public Const REFRESH_FAST = 32768
Public Const CLIENT_LONG_PASSWORD = 1
Public Const CLIENT_FOUND_ROWS = 2
Public Const CLIENT_LONG_FLAG = 4
Public Const CLIENT_CONNECT_WITH_DB = 8
Public Const CLIENT_NO_SCHEMA = 16
Public Const CLIENT_COMPRESS = 32
Public Const CLIENT_ODBC = 64
Public Const CLIENT_LOCAL_FILES = 128
Public Const CLIENT_IGNORE_SPACE = 256
Public Const CLIENT_CHANGE_USER = 512
Public Const CLIENT_INTERACTIVE = 1024
Public Const CLIENT_SSL = 2048
Public Const CLIENT_IGNORE_SIGPIPE = 4096
Public Const CLIENT_TRANSACTIONS = 8196
Public Const SERVER_STATUS_IN_TRANS = 1
Public Const SERVER_STATUS_AUTOCOMMIT = 2
Public Const MYSQL_ERRMSG_SIZE = 200
Public Const NET_READ_TIMEOUT = 30
Public Const NET_WRITE_TIMEOUT = 60
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -