Gambas文档
编译和安装
错误消息
代码片段
待办事项
废弃的组件
教程
开发环境文档
开发者文档
名词解释
如何操作
说明
维基手册
维基搜索
维基许可协议
文档
应用程序仓库
语言概览
语言索引
主题
组件
gb
gb.args
gb.cairo
gb.chart
gb.clipper
gb.complex
gb.compress
gb.crypt
gb.data
gb.db
gb.db.form
gb.db.mysql
gb.db.odbc
gb.db.postgresql
gb.db.sqlite2
gb.db.sqlite3
gb.dbus
gb.dbus.trayicon
gb.debug
gb.desktop
gb.desktop.x11
gb.eval
gb.eval.highlight
gb.form
gb.form.dialog
gb.form.editor
gb.form.htmlview
gb.form.mdi
gb.form.print
gb.form.terminal
gb.gmp
gb.gsl
gb.gtk
gb.gtk3
gb.gtk3.opengl
gb.gtk3.webview
gb.gui
gb.gui.qt
gb.gui.qt.ext
gb.gui.trayicon
gb.gui.webview
gb.hash
gb.highlight
gb.image
gb.image.effect
gb.image.io
gb.inotify
gb.logging
gb.map
gb.media
gb.media.form
gb.mime
gb.mongodb
gb.mysql
gb.ncurses
gb.net
gb.net.curl
gb.net.pop3
gb.net.smtp
gb.opengl
gb.opengl.glsl
gb.opengl.glu
gb.opengl.sge
gb.openssl
gb.option
gb.pcre
gb.pdf
gb.poppler
gb.qt4
gb.qt4.ext
gb.qt4.opengl
gb.qt4.webkit
gb.qt4.webview
gb.qt5
gb.qt5.ext
gb.qt5.opengl
gb.qt5.webview
gb.qt6
gb.qt6.ext
gb.qt6.opengl
gb.qt6.webview
gb.report
gb.report2
gb.sdl
gb.sdl2
gb.sdl2.audio
gb.settings
gb.signal
gb.term
gb.test
gb.util
gb.util.web
gb.v4l
gb.vb
gb.web
gb.web.feed
gb.web.form
gb.web.gui
gb.xml
gb.xml.html
gb.xml.rpc
gb.xml.xslt
最近的修改

Connection (gb.db2)

This class represents a connection to a database.

To connect to a database, create a connection object, fill the needed properties, and call the Open method.

该类是可创建

属性
Charset   Returns the charset used by the database.
Collations   Return the list of collations available in the database
Databases   Returns a collection of all databases managed by the database server.
Error   Returns the code of the last error raised by the database driver.
FullVersion   Return the full version string of the database server.
Handle   Return the handle of the connection.
Host   Returns or sets the host where the database server resides.
IgnoreCharset   Return or set if the database charset should be ignored.
LastInsertId   Return the value of the last serial field used in an INSERT statement.
Login   Returns or sets the user used for establishing the connection.
Name   Returns or sets the name of the database you want to connect to.
Opened   Returns if the connection is opened.
Options   Return or set the connection options.
Password   Returns or sets the password used for establishing the connection.
Port   Returns or sets the TCP/IP port used for establishing the connection.
SQL   Returns a SQLRequest object on that connection.
Tables   Returns a virtual collection used for managing the tables of the database.
Timeout   Return or set the connection timeout in seconds.
Type   Represents the type of the database server you want to connect to.
Url   Return the connection URL.
User   A synonym for the Login property.
Users   Returns a collection of all users registered in the database server.
Version   Returns the version of the database that the driver has connected to.

方法
ApplyTemplate   Apply a template to the connection, i.e. replicate the database structure described by the template string into the current database.
Begin   Start a transaction.
Close   Close the connection.
Commit   Commit a transaction.
Copy   Return a copy of the connection object.
Create   Return a read/write Result object used for creating records in the specified table.
Delete   Removes records from a database table.
Edit   Returns a read/write Result object used for editing records in the specified table.
Exec   Executes an arbitrary SQL request, and returns a read-only Result containing the result of the request.
Find   Returns a read-only Result object used for querying records in the specified table.
GetTemplate   Return the structure of the database as a template string.
Limit   Limits the number of records returned by the next query.
Open   Opens a connection to the specified database.
Quote   Returns a quoted identifier so that you can freely insert it into a query.
Rollback   Cancel a transaction.
Subst   Creates a SQL sentence by substituting its arguments into a format string.

SQLite connections

For SQLite connections, the following algorithm is used:

  • If Name is null, then a memory database is opened.

  • If Name is an absolute path, then this path is used.

  • If Name is a relative path, then:
    • If Host is null, then the database is located in the application temporary directory. See Temp$() for more information.

    • Otherwise, Host gives the database directory, and the database path is the result of concatenating Host and Name.

ODBC connections

For ODBC connections, the following algorithm is used:

  • If Host are defined and also Login, it will connect using it as DSN name.

  • If Host has semicolons at least one, it will assume the property holds a ConnStr.

  • If Host has no semicolons, it will connect using it as DSN name.
    • Otherwise, it will use the ConnStr in .Host to call ODBC SQLDriverConnect function.

See also