-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-odbc.ss
52 lines (38 loc) · 1.42 KB
/
test-odbc.ss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(load-shared-object "msodbcsql18.dll")
(import (prefix (odbc) sql:))
(define environment-handle
(sql:allocate-handle 'environment sql:null-handle))
(sql:set-environment-attribute environment-handle 'odbc-version 3.8)
;; success
(define connection-handle
(sql:allocate-handle 'connection environment-handle))
(define connection-string
(string-append "driver={odbc driver 18 for sql server};"
"server=;"
"database=master;"
"uid=sa;"
"pwd=Password123;"
"encrypt=no;"))
(sql:driver-connect connection-handle connection-string)
;; success-with-info
(sql:get-diagnostic-records 'connection connection-handle)
;; (((sql-state "01000")
;; (native-error 5701)
;; (message-text "[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Changed database context to 'master'."))
;; ((sql-state "01000")
;; (native-error 5703)
;; (message-text "[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Changed language setting to us_english.")))
(define statement-handle
(sql:allocate-handle 'statement connection-handle))
(sql:execute-direct statement-handle "select 1")
;; success
(sql:number-result-columns statement-handle)
;; 1
(sql:free-handle 'statement statement-handle)
;; success
(sql:disconnect connection-handle)
;; success
(sql:free-handle 'connection connection-handle)
;; success
(sql:free-handle 'environment environment-handle)
;; success