本文整理匯總了Golang中C.SQLHDBC函數的典型用法代碼示例。如果您正苦於以下問題:Golang SQLHDBC函數的具體用法?Golang SQLHDBC怎麽用?Golang SQLHDBC使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SQLHDBC函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ClientInfo
func (conn *Connection) ClientInfo() (string, string, string, *ODBCError) {
var info_len C.SQLSMALLINT
p := make([]byte, INFO_BUFFER_LEN)
ret := C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
debugPrint("SQLGetInfo ERROR=", err)
return "", "", "", err
}
drv_name := string(p[0:info_len])
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_ODBC_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
debugPrint("SQLGetInfo ERROR=", err)
return "", "", "", err
}
drv_odbc_ver := string(p[0:info_len])
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DRIVER_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
debugPrint("SQLGetInfo ERROR=", err)
return "", "", "", err
}
drv_ver := string(p[0:info_len])
return drv_name, drv_odbc_ver, drv_ver, nil
}
示例2: ServerInfo
func (conn *Connection) ServerInfo() (string, string, string, *ODBCError) {
var info_len C.SQLSMALLINT
p := make([]byte, INFO_BUFFER_LEN)
ret := C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DATABASE_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
debugPrint("SQLGetInfo ERROR=", err)
return "", "", "", err
}
db := string(p[0:info_len])
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_DBMS_VER, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
debugPrint("SQLGetInfo ERROR=", err)
return db, "", "", err
}
ver := string(p[0:info_len])
ret = C.SQLGetInfo(C.SQLHDBC(conn.Dbc), C.SQL_SERVER_NAME, C.SQLPOINTER(unsafe.Pointer(&p[0])), INFO_BUFFER_LEN, &info_len)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc, int(ret))
debugPrint("SQLGetInfo ERROR=", err)
return db, ver, "", err
}
server := string(p[0:info_len])
return db, ver, server, nil
}
示例3: BeginTransaction
func (conn *Connection) BeginTransaction() (err *ODBCError) {
ret := C.SQLSetConnectAttr(C.SQLHDBC(conn.Dbc), C.SQL_ATTR_AUTOCOMMIT, C.SQLPOINTER(unsafe.Pointer(uintptr(C.SQL_AUTOCOMMIT_OFF))), C.SQL_IS_UINTEGER)
if !Success(ret) {
err = FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
}
return
}
示例4: Connect
func Connect(dsn string, params ...interface{}) (conn *Connection, err *ODBCError) {
var h C.SQLHANDLE
ret := C.SQLAllocHandle(C.SQL_HANDLE_DBC, Genv, &h)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, h)
return nil, err
}
var stringLength2 C.SQLSMALLINT
outBuf := make([]byte, BUFFER_SIZE*2)
outConnectionString := (*C.SQLWCHAR)(unsafe.Pointer(&outBuf[0]))
ret = C.SQLDriverConnectW(C.SQLHDBC(h),
C.SQLHWND(unsafe.Pointer(uintptr(0))),
(*C.SQLWCHAR)(unsafe.Pointer(StringToUTF16Ptr(dsn))),
C.SQL_NTS,
outConnectionString,
BUFFER_SIZE,
&stringLength2,
C.SQL_DRIVER_NOPROMPT)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, h)
return nil, err
}
return &Connection{Dbc: h, connected: true}, nil
}
示例5: AutoCommit
func (conn *Connection) AutoCommit(b bool) (err *ODBCError) {
var n C.int
if b {
n = C.SQL_AUTOCOMMIT_ON
} else {
n = C.SQL_AUTOCOMMIT_OFF
}
ret := C.SQLSetConnectAttr(C.SQLHDBC(conn.Dbc), C.SQL_ATTR_AUTOCOMMIT, C.SQLPOINTER(unsafe.Pointer(uintptr(n))), C.SQL_IS_UINTEGER)
if !Success(ret) {
err = FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
}
return
}
示例6: Close
func (conn *Connection) Close() *ODBCError {
if conn.connected {
ret := C.SQLDisconnect(C.SQLHDBC(conn.Dbc))
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
return err
}
ret = C.SQLFreeHandle(C.SQL_HANDLE_DBC, conn.Dbc)
if !Success(ret) {
err := FormatError(C.SQL_HANDLE_DBC, conn.Dbc)
return err
}
conn.connected = false
}
return nil
}
示例7: SQLDriverConnect
func SQLDriverConnect(connectionHandle SQLHDBC, windowHandle SQLHWND, inConnectionString *SQLWCHAR, stringLength1 SQLSMALLINT, outConnectionString *SQLWCHAR, bufferLength SQLSMALLINT, stringLength2Ptr *SQLSMALLINT, driverCompletion SQLUSMALLINT) (ret SQLRETURN) {
r := C.SQLDriverConnectW(C.SQLHDBC(connectionHandle), C.SQLHWND(windowHandle), (*C.SQLWCHAR)(unsafe.Pointer(inConnectionString)), C.SQLSMALLINT(stringLength1), (*C.SQLWCHAR)(unsafe.Pointer(outConnectionString)), C.SQLSMALLINT(bufferLength), (*C.SQLSMALLINT)(stringLength2Ptr), C.SQLUSMALLINT(driverCompletion))
return SQLRETURN(r)
}
示例8: SQLDisconnect
func SQLDisconnect(connectionHandle SQLHDBC) (ret SQLRETURN) {
r := C.SQLDisconnect(C.SQLHDBC(connectionHandle))
return SQLRETURN(r)
}
示例9: SQLSetConnectAttr
func SQLSetConnectAttr(connectionHandle SQLHDBC, attribute SQLINTEGER, valuePtr SQLPOINTER, stringLength SQLINTEGER) (ret SQLRETURN) {
r := C.SQLSetConnectAttrW(C.SQLHDBC(connectionHandle), C.SQLINTEGER(attribute), C.SQLPOINTER(valuePtr), C.SQLINTEGER(stringLength))
return SQLRETURN(r)
}
示例10: SQLSetConnectUIntPtrAttr
func SQLSetConnectUIntPtrAttr(connectionHandle SQLHDBC, attribute SQLINTEGER, valuePtr uintptr, stringLength SQLINTEGER) (ret SQLRETURN) {
r := C.sqlSetConnectUIntPtrAttr(C.SQLHDBC(connectionHandle), C.SQLINTEGER(attribute), C.uintptr_t(valuePtr), C.SQLINTEGER(stringLength))
return SQLRETURN(r)
}