File: manual.texi

package info (click to toggle)
myodbc 3.51.09-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,400 kB
  • ctags: 1,596
  • sloc: ansic: 29,806; sh: 10,765; cpp: 627; makefile: 610
file content (1898 lines) | stat: -rw-r--r-- 72,846 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
\input texinfo  @c -*-texinfo-*-
@c Copyright 1995-2002 MySQL AB
@c
@c This manual is NOT distributed under a GPL style license.
@c Use of the manual is subject to the following terms:
@c - Conversion to other formats is allowed, but the actual
@c   content may not be altered or edited in any way.
@c - You may create a printed copy for your own personal use.
@c - For all other uses, such as selling printed copies or
@c   using (parts of) the manual in another publication,
@c   prior written agreement from MySQL AB is required.
@c
@c Please e-mail docs@mysql.com for more information or if
@c you are interested in doing a translation.
@c
@c *********************************************************
@c Note that @node names are used on our web site.
@c So do not change node names without checking
@c Makefile.am and SitePages first.
@c *********************************************************
@c
@c %**start of header

@setfilename manual.info

@c We want the types in the same index
@c syncodeindex tp fn

@c Get version information. This file is generated by the Makefile!!
@c @include include.texi

@ifclear tex-debug
@c This removes the black squares in the right margin
@finalout
@end ifclear

@c Set background for HTML
@set _body_tags BGCOLOR=#FFFFFF TEXT=#000000 LINK=#003366 VLINK=#001933
@c Set some style elements for the manual in HTML form. 'suggested'
@c natural language colors: aqua, black, blue, fuchsia, gray, green,
@c lime, maroon, navy, olive, purple, red, silver, teal, white, and
@c yellow. From Steeve Buehler <ahr@YogElements.com>
@set _extra_head <style> code {color:purple} tt {color:green} samp {color:navy} pre {color:maroon} </style>

@settitle Connector/ODBC Programmer's Reference Manual

@c We want single-sided heading format, with chapters on new pages. To
@c get double-sided format change 'on' below to 'odd'
@setchapternewpage on

@paragraphindent 0

@c %**end of header

@ifinfo
@format
START-INFO-DIR-ENTRY
* manual: (manual).               Connector/ODBC documentation.
END-INFO-DIR-ENTRY
@end format
@end ifinfo

@titlepage
@sp 10
@center @titlefont{Connector/ODBC Programmer's Reference Manual}
@sp 10
@center Copyright @copyright{} 1995-2003 MySQL AB
@center   @uref{http://www.mysql.com}
@c blank page after title page makes page 1 be a page front.
@c also makes the back of the title page blank.
@page
@end titlepage

@c Short contents, blank page, long contents.
@c until i can figure out the blank page, no short contents.
@c @shortcontents
@c @page
@c @page
@contents

@c This should be added. The HTML conversion also needs a Connector/ODBC version
@c number somewhere.

@iftex
@c change this to double if you want formatting for double-sided
@c printing
@headings single

@oddheading @thischapter @| @| @thispage
@evenheading @thispage @| @| Connector/ODBC Programmer's Reference Manual 
for Version @value{myodbc3_version}

@end iftex


@node Top, Introduction, (dir), (dir)

@ifinfo
This is the manual of the Connector/ODBC driver, which provides ODBC 3.51 
compliant access to the MySQL Database System. 
This version is about the @value{myodbc3_version} version of 
Connector/ODBC. You can find a specific manual for any older version of 
Connector/ODBC in the binary or source distribution for that version.
@end ifinfo



@menu
* Introduction::                Introduction
* General Information::         General Information About ODBC and Connector/ODBC
* Developing Applications Using Connector/ODBC::  Developing Applications Using Connector/ODBC
* Connector/ODBC API Reference::  Connector/ODBC API Reference
* Connector/ODBC Data Types::   Connector/ODBC Data Types
* Connector/ODBC Error Codes::  Connector/ODBC Error Codes
* Connector/ODBC With VB::      Connector/ODBC with ADO, DAO and RDO
* Connector/ODBC With .NET::    Connector/ODBC with Microsoft .NET
* Credits::                     Credits
@end menu

@node Introduction, General Information, Top, Top
@chapter Introduction

@menu
* What is MySQL::               What is MySQL
* What is MySQL AB::            What is MySQL AB
* What is MyODBC::              What is MyODBC
* What is MyODBC 3.51::         What is MyODBC 3.51
* About This Manual ::          About This Manual
* Intended Audience ::          Intended Audience
@end menu

@node What is MySQL, What is MySQL AB, Introduction, Introduction
@section What is MySQL
@code{MySQL}, the most popular Open Source SQL database, is developed
and provided by @code{MySQL AB}. @code{MySQL AB} is a commercial company
that builds its business providing services around the @code{MySQL} database.
The @code{MySQL} web site (@uref{http://www.mysql.com/}) provides
the latest information about @code{MySQL} software and @code{MySQL AB}.



@node What is MySQL AB, What is MyODBC, What is MySQL, Introduction
@section What is MySQL AB
@code{MySQL AB} is the Swedish company owned and run by the @code{MySQL}
founders and main developers. We are dedicated to developing @code{MySQL}
and spreading our database to new users. @code{MySQL AB} owns the
copyright to the @code{MySQL} server source code and the @code{MySQL}
trademark. A significant amount of revenues from our services goes to
developing @code{MySQL}.



@node What is MyODBC, What is MyODBC 3.51, What is MySQL AB, Introduction
@section What is MyODBC

@code{@strong{MyODBC 2.50}} is a 32-bit ODBC Driver from @code{@strong{MySQL AB}},
which is based on @strong{ODBC 2.50 specification} Level 0 (with level 1 and 2 
features). This is one of the most popular ODBC Driver in the open source 
market, used by many users to access the MySQL functionality.


@node What is MyODBC 3.51, About This Manual , What is MyODBC, Introduction
@section What is MyODBC 3.51
.
@code{@strong{MyODBC 3.51}} is a 32-bit ODBC Driver, also known as MySQL ODBC 
3.51 Driver. This is a enhanced version to the existing MyODBC 2.50, with 
@strong{ODBC 3.5x specification} level 1(complete core API + level 2 features) 
in order to continue to provide all functionality of ODBC to access MySQL.


@node About This Manual , Intended Audience , What is MyODBC 3.51, Introduction
@section About This Manual
This manual contains information about the usage of MySQL ODBC Drivers,
MyODBC and MyODBC 3.51, in order to explore MySQL capabilities by means
of ODBC API.

Note, as this manual is a reference to the ODBC programming for the
MySQL ODBC Drivers, not all ODBC concepts and practices may be covered
fully.
The manual is currently available in Texinfo, Info, plain text and HTML
formats,
and is being maintained by Monty Widenius, Venu Anuganti and Arjen Lentz.
For any changes or contributions to the manual, please send a mail to
@email{docs@@mysql.com} or to @email{myodbc@@lists.mysql.com}.




@node Intended Audience ,  , About This Manual , Introduction
@section Intended Audience
This manual assumes a good working knowledge of C, general DBMS knowledge,
and finally, but not least, familiarity with MySQL.
For more information about MySQL functionality and its syntax, refer to
@uref{http://www.mysql.com/documentation/index.html}.



@node General Information, Developing Applications Using Connector/ODBC, Introduction, Top
@chapter General Information About ODBC and Connector/ODBC
This chapter contains the general information about ODBC and Connector/ODBC.

@menu
* Introduction to ODBC::        Introduction to ODBC
* Connector/ODBC Architecture::  
* Types of MySQL ODBC Drivers::  Types of MySQL ODBC Drivers
* Where Can I Get Connector/ODBC::  Where Can I Get Connector/ODBC
* How To Install Connector/ODBC::  How To Install Connector/ODBC
* Supported Platforms::         Supported Platforms
* Connector/ODBC Mailing List::  Connector/ODBC Mailing List
* Connector/ODBC Support ::     Connector/ODBC Support
* Reporting Problems::          How to Report Connector/ODBC Problems or Bugs
* Programs Known to Work With Connector/ODBC::  Programs Known to Work With Connector/ODBC
@end menu



@node Introduction to ODBC, Connector/ODBC Architecture, General Information, General Information
@section Introduction to ODBC
Open Database Connectivity (ODBC) is a widely accepted application-programming
interface (API) for database access. It is based on the Call-Level Interface
(CLI) specifications from X/Open and ISO/IEC for database APIs and uses
Structured Query Language (SQL) as its database access language. 

For more information about ODBC, see @uref{http://www.microsoft.com/data/}.


@node Connector/ODBC Architecture, Types of MySQL ODBC Drivers, Introduction to ODBC, General Information
@section Connector/ODBC Architecture

The Connector/ODBC architecture has mainly 5 components as shown below:

@* @image{Images/myarchitecture}

@table @strong
@item Application:

An application is a program that calls the ODBC API to access the
data from (MySQL) server. The Application communicates with the
Driver Manager using the standard ODBC calls.
The Application does not care, where the data is stored, how it
is stored or even how the system is configured to access the data.
It only needs to know the Data Source Name (DSN).

A number of tasks are common to all applications, no matter how they use ODBC.
These tasks are:
@itemize @bullet
@item Selecting the (MySQL) server and connecting to it.
@item Submitting an SQL statement for execution.
@item Retrieving results (if any).
@item Processing errors.
@item Committing or rolling back the transaction enclosing the SQL statement.
@item Disconnecting from the (MySQL) server.
@end itemize

Because most data access work is done with SQL, the primary task for which
applications use ODBC is to submit SQL statements and retrieve the results (if
any) generated by those statements.

@*
@item Driver manager:

The Driver Manager is a library that manages communication
between application and driver or drivers. It does:
@itemize @bullet
@item Resolves Data Source Names (DSN).
@item Loading and unloading of the drivers.
@item Processes ODBC function calls or passes them to the driver.
@end itemize

@*
@item Connector/ODBC Driver:

Connector/ODBC Driver is a library that implements the functions in the
ODBC API. It processes ODBC function calls, submits SQL requests to MySQL
server, and returns results back to the application. If necessary, the driver
modifies an application's request so that the request conforms to syntax
supported by the MySQL.

@*
@item ODBC.INI:

ODBC.INI is the ODBC configuration file, which stores the driver and
database information required to connect to the server. It is used by
the Driver Manager to determine which driver to be loaded using the
Data Source Name.
Driver uses this to read connection parameters based on the DSN specified.
For more information, @ref{Configuring Connector/ODBC DSN}.

@*
@item MySQL SERVER:

It is the source of data. MySQL is
@itemize @bullet
@item Data base management system (DBMS)
@item Relational database management system (RDBMS)
@item Open Source Software
@end itemize

@end table



@node Types of MySQL ODBC Drivers, Where Can I Get Connector/ODBC, Connector/ODBC Architecture, General Information
@section Types of MySQL ODBC Drivers

As described earlier, MySQL AB supports two Open Source ODBC drivers,
namely MyODBC(Connector/ODBC 2.50) and MySQL ODBC 3.51
Driver(Connector/ODBC 3.51), to access MySQL functionality
through the ODBC API.

Note, from this section of the manual onwards, we refer both the drivers
as Connector/ODBC itself, and whenever there is a difference then we keep the
original names.



@node Where Can I Get Connector/ODBC, How To Install Connector/ODBC, Types of MySQL ODBC Drivers, General Information
@section Where Can I Get Connector/ODBC

MySQL AB distributes all its products under General Public License (GPL).
You can get the latest, free copy of Connector/ODBC driver
binaries and sources from its website @uref{http://www.mysql.com/}.
For more information about MySQL ODBC Drivers, visit
@uref{http://www.mysql.com/downloads/api-myodbc.html}.



@node How To Install Connector/ODBC, Supported Platforms, Where Can I Get Connector/ODBC, General Information
@section How To Install Connector/ODBC

For complete information on Connector/ODBC installation refer
@uref{http://www.mysql.com/products/myodbc/faq_2.html#Installation, here}.


@node Supported Platforms, Connector/ODBC Mailing List, How To Install Connector/ODBC, General Information
@section Supported Platforms
MySQL ODBC Drivers can be used on all major platforms supported by MySQL,
such as:

@itemize @bullet
@item All Windows platforms, 95/98 and NT/ME/2000/XP
@item All Unix Operating Systems
@itemize @bullet
@item AIX
@item Amiga
@item BSDI
@item DEC
@item FreeBSD
@item HP-UX
@item Linux
@item Mac OS X Server
@item NetBSD
@item OpenBSD
@item OS/2
@item SGI Irix
@item Solaris
@item SunOS
@item SCO OpenServer
@item SCO UnixWare
@item Tru64 Unix
@end itemize
@end itemize

In General, Connector/ODBC (3.51) is supported in all the platforms that
MySQL supports.
If the binary distribution is not available for downloading for a
particular platform, then you can build the driver yourself, by
downloading the driver sources and contribute the binaries to MySQL,
by sending a mail to @email{myodbc@@lists.mysql.com}, so that it
becomes easy for other users.



@node Connector/ODBC Mailing List, Connector/ODBC Support , Supported Platforms, General Information
@section Connector/ODBC Mailing List
MySQL provides the user community by means of its mailing lists,
where in you get the solutions from experienced users, by sending
your queries to @email{myodbc@@lists.mysql.com}.

To subscribe to the Connector/ODBC mailing list, send a message to
@email{myodbc-subscribe@@lists.mysql.com}.
To unsubscribe from the Connector/ODBC mailing list, send a message to
@email{myodbc-unsubscribe@@lists.mysql.com}.
You can also browse the mailing list archives at
@uref{http://lists.mysql.com/}.



@node Connector/ODBC Support , Reporting Problems, Connector/ODBC Mailing List, General Information
@section Connector/ODBC Support
For the success of any product, support from the product vendor or the
development team plays a key role. If you want:

@example
  * Bugs to be resolved within time.
  * To have the immediate patches delivered directly to your mailbox.
  * To ask a feature in the driver.
  * To have enhancement to the driver.
  * To resolve any Connector/ODBC or MySQL issues.
  * To have direct interaction with MySQL and Connector/ODBC developers.
@end example

Then, you need to get a support contract from @code{MySQL AB}.
@code{MySQL AB} supports different types of support licenses in order 
to help you by keeping your requirements and ability to purchase it.
For more information about MySQL support, visit @uref{https://order.mysql.com/} 
or send a mail to @email{licensing@@mysql.com}.

Once you have the support means, you can send queries or bug reports
using the MySQL support wizard from @uref{http://support.mysql.com/},
then the MySQL team will work on your problem immediately until it got
resolved.



@node Reporting Problems, Programs Known to Work With Connector/ODBC, Connector/ODBC Support , General Information
@section How to Report Connector/ODBC Problems or Bugs

On how to report a problem with Connector/ODBC or MySQL refer to
@uref{http://www.mysql.com/products/myodbc/faq_1.html#Reporting_Problems,
here}.


@node Programs Known to Work With Connector/ODBC,  , Reporting Problems, General Information
@section Programs Known to Work With Connector/ODBC

Most programs should work with @strong{Connector/ODBC}, but for each of those
listed below, we have tested it ourselves or received confirmation from
some user that it works.

@table @asis
@item @strong{Program}
@strong{Comment}
@cindex Access program

@item Access
To make Access work:
@itemize @bullet
@item
If you are using Access 2000, you should get and install the newest
(version 2.6 or above) Microsoft MDAC (@code{Microsoft Data Access
Components}) from @uref{http://www.microsoft.com/data/}.  This will fix
the following bug in Access: when you export data to MySQL, the
table and column names aren't specified.  Another way to around this bug
is to upgrade to Connector/ODBC Version 2.50.33 and MySQL Version
3.23.x, which together provide a workaround for this bug!

You should also get and apply the Microsoft Jet 4.0 Service Pack 5 (SP5)
which can be found here
@uref{http://support.microsoft.com/default.aspx?scid=kb;EN-US;q239114}.
This will fix some cases where columns are marked as @code{#deleted#}
in Access.

Note that if you are using MySQL Version 3.22, you must to apply the
MDAC patch and use Connector/ODBC 2.50.32 or 2.50.34 and above to go around
this problem.
@item
For all Access versions, you should enable the Connector/ODBC option flag
@code{Return matching rows}. For Access 2.0, you should additionally enable
@code{Simulate ODBC 1.0}.
@item
You should have a timestamp in all tables you want to be able to update.
For maximum portability @code{TIMESTAMP(14)} or simple @code{TIMESTAMP}
is recommended instead of other @code{TIMESTAMP(X)} variations.
@item
You should have a primary key in the table. If not, new or updated rows
may show up as @code{#DELETED#}.
@item
Only use @code{DOUBLE} float fields. Access fails when comparing with
single floats.  The symptom usually is that new or updated rows may show
up as @code{#DELETED#} or that you can't find or update rows.
@item
If you are linking a table through Connector/ODBC, which has @code{BIGINT} as
one of the column, then the results will be displayed as @code{#DELETED}. The
work around solution is:
@itemize @bullet
@item
Have one more dummy column with @code{TIMESTAMP} as the data type, preferably
@code{TIMESTAMP(14)}.
@item
Check the @code{'Change BIGINT columns to INT'} in connection options dialog in
ODBC DSN Administrator
@item
Delete the table link from access and re-create it.
@end itemize

It still displays the previous records as @code{#DELETED#}, but newly
added/updated records will be displayed properly.
@item
If you still get the error @code{Another user has changed your data} after
adding a @code{TIMESTAMP} column, the following trick may help you:

Don't use @code{table} data sheet view. Create instead a form with the
fields you want, and use that @code{form} data sheet view.  You should
set the @code{DefaultValue} property for the @code{TIMESTAMP} column to
@code{NOW()}.  It may be a good idea to hide the @code{TIMESTAMP} column
from view so your users are not confused.
@item
In some cases, Access may generate illegal SQL queries that
MySQL can't understand. You can fix this by selecting
@code{"Query|SQLSpecific|Pass-Through"} from the Access menu.
@item
Access on NT will report @code{BLOB} columns as @code{OLE OBJECTS}. If
you want to have @code{MEMO} columns instead, you should change the
column to @code{TEXT} with @code{ALTER TABLE}.
@item
Access can't always handle @code{DATE} columns properly. If you have a problem
with these, change the columns to @code{DATETIME}.
@item
If you have in Access a column defined as @code{BYTE}, Access will try
to export this as @code{TINYINT} instead of @code{TINYINT UNSIGNED}.
This will give you problems if you have values > 127 in the column!
@end itemize

@cindex ADO program
@item ADO
When you are coding with the ADO API and @strong{Connector/ODBC} you need to put
attention in some default properties that aren't supported by the
MySQL server.  For example, using the @code{CursorLocation
Property} as @code{adUseServer} will return for the @code{RecordCount
Property} a result of -1. To have the right value, you need to set this
property to @code{adUseClient}, like is showing in the VB code below:

@example
Dim myconn As New ADODB.Connection
Dim myrs As New Recordset
Dim mySQL As String
Dim myrows As Long

myconn.Open "DSN=MyODBCsample"
mySQL = "SELECT * from user"
myrs.Source = mySQL
Set myrs.ActiveConnection = myconn
myrs.CursorLocation = adUseClient
myrs.Open
myrows = myrs.RecordCount

myrs.Close
myconn.Close
@end example

Another workaround is to use a @code{SELECT COUNT(*)} statement
for a similar query to get the correct row count.

@item Active server pages (ASP)
You should use the option flag @code{Return matching rows}.

@item BDE applications
To get these to work, you should set the option flags
@code{Don't optimize column widths} and @code{Return matching rows}.

@cindex Borland Builder 4 program
@item Borland Builder 4
When you start a query you can use the property @code{Active} or use the
method @code{Open}.  Note that @code{Active} will start by automatically
issuing a @code{SELECT * FROM ...} query that may not be a good thing if
your tables are big!

@item ColdFusion (On Unix)
The following information is taken from the ColdFusion documentation:

Use the following information to configure ColdFusion Server for Linux
to use the unixODBC driver with @strong{Connector/ODBC} for MySQL data
sources.  Allaire has verified that @strong{Connector/ODBC} Version 2.50.26
works with MySQL Version 3.22.27 and ColdFusion for Linux. (Any
newer version should also work.) You can download @strong{Connector/ODBC} at
@uref{http://www.mysql.com/downloads/api-myodbc.html}

@cindex ColdFusion program
ColdFusion Version 4.5.1 allows you to us the ColdFusion Administrator
to add the MySQL data source. However, the driver is not
included with ColdFusion Version 4.5.1. Before the MySQL driver
will appear in the ODBC datasources drop-down list, you must build and
copy the @strong{Connector/ODBC} driver to
@file{/opt/coldfusion/lib/libmyodbc.so}.

The Contrib directory contains the program mydsn-xxx.zip which allows
you to build and remove the DSN registry file for the Connector/ODBC driver
on Coldfusion applications.

@cindex DataJunction
@item DataJunction
You have to change it to output @code{VARCHAR} rather than @code{ENUM}, as
it exports the latter in a manner that causes MySQL grief.

@cindex Excel
@item Excel
Works. A few tips:
@itemize @bullet
@item
If you have problems with dates, try to select them as strings using the
@code{CONCAT()} function. For example:
@example
select CONCAT(rise_time), CONCAT(set_time)
    from sunrise_sunset;
@end example
Values retrieved as strings this way should be correctly recognized
as time values by Excel97.

The purpose of @code{CONCAT()} in this example is to fool ODBC into thinking
the column is of ``string type''. Without the @code{CONCAT()}, ODBC knows the
column is of time type, and Excel does not understand that.

Note that this is a bug in Excel, because it automatically converts a
string to a time. This would be great if the source was a text file, but
is plain stupid when the source is an ODBC connection that reports
exact types for each column.
@end itemize
@cindex Word program
@item Word

To retrieve data from MySQL to Word/Excel documents, you need to
use the @code{Connector/ODBC} driver and the Add-in Microsoft Query help.

For example, create a db with a table containing 2 columns of text:

@itemize @bullet
@item
Insert rows using the @code{mysql} client command-line tool.
@item
Create a DSN file using the Connector/ODBC driver, for example, my for the db above.
@item
Open the Word application.
@item
Create a blank new documentation.
@item
Using the tool bar called Database, press the button insert database.
@item
Press the button Get Data.
@item
At the right hand of the screen Get Data, press the button Ms Query.
@item
In the Ms Query create a New Data Source using the DSN file my.
@item
Select the new query.
@item
Select the columns that you want.
@item
Make a filter if you want.
@item
Make a Sort if you want.
@item
Select Return Data to Microsoft Word.
@item
Click Finish.
@item
Click Insert data and select the records.
@item
Click OK and you see the rows in your Word document.
@end itemize

@cindex odbcadmin program
@item odbcadmin
Test program for ODBC.

@cindex Delphi program
@item Delphi
You must use BDE Version 3.2 or newer.  Set the @code{Don't optimize column width}
option field when connecting to MySQL.

Also, here is some potentially useful Delphi code that sets up both an
ODBC entry and a BDE entry for @strong{Connector/ODBC} (the BDE entry requires a BDE
Alias Editor that is free at a Delphi Super Page near
you. (Thanks to Bryan Brunton @email{bryan@@flesherfab.com} for this):

@example
fReg:= TRegistry.Create;
  fReg.OpenKey('\Software\ODBC\ODBC.INI\DocumentsFab', True);
  fReg.WriteString('Database', 'Documents');
  fReg.WriteString('Description', ' ');
  fReg.WriteString('Driver', 'C:\WINNT\System32\myodbc.dll');
  fReg.WriteString('Flag', '1');
  fReg.WriteString('Password', '');
  fReg.WriteString('Port', ' ');
  fReg.WriteString('Server', 'xmark');
  fReg.WriteString('User', 'winuser');
  fReg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', True);
  fReg.WriteString('DocumentsFab', 'MySQL');
  fReg.CloseKey;
  fReg.Free;

  Memo1.Lines.Add('DATABASE NAME=');
  Memo1.Lines.Add('USER NAME=');
  Memo1.Lines.Add('ODBC DSN=DocumentsFab');
  Memo1.Lines.Add('OPEN MODE=READ/WRITE');
  Memo1.Lines.Add('BATCH COUNT=200');
  Memo1.Lines.Add('LANGDRIVER=');
  Memo1.Lines.Add('MAX ROWS=-1');
  Memo1.Lines.Add('SCHEMA CACHE DIR=');
  Memo1.Lines.Add('SCHEMA CACHE SIZE=8');
  Memo1.Lines.Add('SCHEMA CACHE TIME=-1');
  Memo1.Lines.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
  Memo1.Lines.Add('SQLQRYMODE=');
  Memo1.Lines.Add('ENABLE SCHEMA CACHE=FALSE');
  Memo1.Lines.Add('ENABLE BCD=FALSE');
  Memo1.Lines.Add('ROWSET SIZE=20');
  Memo1.Lines.Add('BLOBS TO CACHE=64');
  Memo1.Lines.Add('BLOB SIZE=32');

  AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines);
@end example

@cindex C++ Builder
@item C++ Builder
Tested with BDE Version 3.0. The only known problem is that when the table
schema changes, query fields are not updated. BDE, however, does not seem
to recognise primary keys, only the index PRIMARY, though this has not
been a problem.

@item Vision
You should use the option flag @code{Return matching rows}.

@cindex Visual Basic
@item Visual Basic
To be able to update a table, you must define a primary key for the table.

Visual Basic with ADO can't handle big integers. This means that some queries
like @code{SHOW PROCESSLIST} will not work properly.  The fix is to set
add the option @code{OPTION=16834} in the ODBC connect string or set
the @code{Change BIGINT columns to INT} option in the Connector/ODBC connect screen.
You may also want to set the @code{Return matching rows} option.

@item VisualInterDev
If you get the error @code{[Microsoft][ODBC Driver Manager] Driver does
not support this parameter} the reason may be that you have a
@code{BIGINT} in your result.  Try setting the @code{Change BIGINT
columns to INT} option in the Connector/ODBC connect screen.

@item Visual Objects
You should use the option flag @code{Don't optimize column widths}.

@item MS Visio Enterprise 2000
We made database model diagram by connecting from MS Vision Enterprise 
2000 to MySQL via Connector/ODBC(2.50.37 or greater) and using Visio's reverse 
engineer function to retrieve information about the DB (Visio shows all 
the column definitions, primary keys, Indexes and so on). Also we tested 
by designing new tables in Visio and exported them to MySQL via Connector/ODBC.
@end table

For the complte list, refer
@uref{http://www.mysql.com/products/myodbc/faq_7.html#Tested_Applications,
here}.

@c
@c CHAPTER 3
@c


@node Developing Applications Using Connector/ODBC, Connector/ODBC API Reference, General Information, Top
@chapter Developing Applications Using Connector/ODBC

This chapter contains information about developing applications to access MySQL 
server that use Connector/ODBC as the interface.


@menu
* Basic Connector/ODBC application steps ::  Basic Connector/ODBC application steps
* Configuring Connector/ODBC DSN ::  Configuring Connector/ODBC DSN
* Connection parameters ::      Connection parameters
@c * Connecting to MySQL server ::  Connecting to MySQL server
@c * Executing SQL Statements ::   Executing SQL Statements
@c * Retrieving Results ::         Retrieving Results
@c * Cursor Operations ::          Cursor Operations
@c * Catalog Functions ::          Catalog Functions
@c * Transaction Control ::        Transaction Control
@c * Getting Diagnostic Information ::  Getting Diagnostic Information
@end menu

@node Basic Connector/ODBC application steps , Configuring Connector/ODBC DSN , Developing Applications Using Connector/ODBC, Developing Applications Using Connector/ODBC
@section Basic Connector/ODBC application steps 

More or less, to interact with MySQL server from any Connector/ODBC application, 
involves the following steps of operations:

@itemize @bullet    
@item Configuring the Connector/ODBC DSN
@item Connecting to MySQL server
@item Initializations
@item Execution of SQL statements
@item Retrieving results
@item Performing Transactions
@item Disconnecting from the server
@end itemize

Most applications use some variation of these steps. The basic application 
steps are shown in the following diagram:

@*@* @image{Images/myflowchart} @*@*


@node Configuring Connector/ODBC DSN , Connection parameters , Basic Connector/ODBC application steps , Developing Applications Using Connector/ODBC
@section Configuring Connector/ODBC DSN 

A data source identifies a path to data that can include a network
library, server, database, and other attributes-in this case; the
data source is the path to @code{MySQL} database. To connect to a
data source, the Driver Manager checks the Windows registry for
specific connection information.

To use Connector/ODBC, you must use a Driver Manager. You cannot link
directly to the myodbc3 library.

The @code{ODBC Driver Manager} and @code{Connector/ODBC Drivers} use the
registry entry created by the @code{ODBC Data Source Administrator}.
This entry contains information about each data source and its
associated driver. Before you can connect to a data source, its
connection information must be added to the registry.


To add and configure data sources, use the @code{@strong{ODBC Data Source
Administrator}}. The @code{@strong{ODBC Administrator}} updates your data
source connection information. As you add data sources, the
@code{@strong{ODBC Administrator}} updates the registry information for you.

@strong{To open the @code{@strong{ODBC Administrator}} from the Control Panel:}

@itemize
@item
Click @code{@strong{Start}}, point to @code{@strong{Settings}}, and then click @code{@strong{Control Panel}}.
@item
On computers running Microsoft Windows 2000, double-click
@code{@strong{Administrative Tools}}, and then double-click @code{@strong{Data
Sources (ODBC)}}.On computers running previous versions of Microsoft Windows,
double-click @code{@strong{32-bit ODBC}} or @code{@strong{ODBC}}.

@*@* @image{Images/mydsn-icon} @*

The @code{@strong{ODBC Data Source Administrator}} dialog box appears, as 
shown below.

@*@* @image{Images/mydsn} @*@*


Click Help for detailed information about each tab of the @code{@strong{ODBC Data
Source Administrator}} dialog box.@*@*
@end itemize

@strong{To add a data source on Windows:}@*

@enumerate
@item
Open the @code{@strong{ODBC Data Source Administrator}}.
@item
In the @code{@strong{ODBC Data Source Administrator}} dialog box, click
@code{Add}. The @code{@strong{Create New Data Source}} dialog box appears.
@item
Select @code{@strong{MySQL ODBC 3.51 Driver}}, and then click @code{@strong{Finish}}.
The @code{@strong{MySQL ODBC 3.51 Driver - DSN Configuration}} dialog box
appears, as shown below:

@*@* @image{Images/mydsn-setup} @*@*

@item
In the @code{@strong{Data Source Name}} box, type the name of the data
source you want to access. It can be any valid name that you choose.
@item
In the @code{@strong{Description}} box, type the description needed for the DSN.
@item
In the @code{@strong{Host or Server Name (or IP)}}, type the MySQL server name
that you want to access. By default it is 'local host'.
@item
In the @code{@strong{Database Name}}, type the name of the MySQL database
that you want to use it as the default database.
@item
In the @code{@strong{User}} box, type your database user name (your database
user ID).
@item
In the @code{@strong{Password}} box, type your pass word
@item
In the @code{@strong{Port}} box, type the port number if it is not the
default 3306.
@item
In the @code{@strong{SQL Command}} box, you can enter the optional SQL command
that you want to use it after the connection. 

The final dialog look like:

@end enumerate

@itemize
@* @image{Images/mydsn-example} @*@*

Click @code{@strong{OK}} to add this data source.

@code{@strong{Note:}}Upon clicking OK, the Data Sources dialog box appears, and
the @code{@strong{ODBC Administrator}} updates the registry information. The user
name and connect string that you typed become the default connection
values for this data source when you connect to it.

You can also @code{test} whether your settings are enough to connect to the
server using the button @code{@strong{Test Data Source}}. This feature is available
only for @code{Connector/ODBC 3.51} driver. Here are the screen shots of @code{Test
Data Source} results for successful and failed connection:

@*@* @image{Images/mydsn-test-success} @*

@* @image{Images/mydsn-test-fail} @*@*

@*
@strong{Driver Options}:
You can also see the @code{@strong{Options}} button, which will display
the advanced options dialog as show below; which controls the driver 
behaviour. You can refer to @ref{Connection parameters}, to know more 
about these options.

@*@* @image{Images/mydsn-options} @*@*

@strong{Note} that the @code{Driver Trace Options} will be disabled 
(grayed out) when using the release(share) version of driver DLL.

@end itemize

@*@*
@strong{To modify a data source on Windows}:

@enumerate

@item
Open the @code{@strong{ODBC Data Source Administrator}}. Click the appropriate DSN tab.
@item
Select the MySQL data source you want to @code{@strong{modify}} and then click @code{@strong{Configure}}.
The @code{@strong{MySQL ODBC 3.51 Driver - DSN Configuration}} dialog box appears.
@item
Modify the applicable data source fields, and then click @code{@strong{OK}}.

@end enumerate

When you have finished modifying the information in this dialog box, the
@code{@strong{ODBC Administrator}} updates the registry information.
@*

@strong{To configure data source on Unix}:

On @code{Unix}, you can configure the @code{DSN} entries directly in the
ODBC.INI file. Here is an example of odbc.ini file, with 'myodbc' as the 
DSN name for Connector/ODBC 2.50 and myodbc3 for Connector/ODBC 3.51 Drivers:

@example
  ;
  ;  odbc.ini configuration for Connector/ODBC and Connector/ODBC 3.51 Drivers
  ;
  @strong{[ODBC Data Sources]}
  myodbc      = MySQL ODBC 2.50 Driver DSN 
  myodbc3     = MySQL ODBC 3.51 Driver DSN

  @strong{[myodbc]}
  Driver       = /usr/local/lib/libmyodbc.so
  Description  = MySQL ODBC 2.50 Driver DSN
  SERVER       = localhost
  PORT         =
  USER         = root
  Password     =
  Database     = test
  OPTION       = 3
  SOCKET       = 

  @strong{[myodbc3]}
  Driver       = /usr/local/lib/libmyodbc3.so
  Description  = MySQL ODBC 3.51 Driver DSN
  SERVER       = localhost
  PORT         =
  USER         = root
  Password     =
  Database     = test
  OPTION       = 3
  SOCKET       = 

  @strong{[Default]}
  Driver       = /usr/local/lib/libmyodbc3.so
  Description  = MySQL ODBC 3.51 Driver DSN
  SERVER       = localhost
  PORT         =
  USER         = root
  Password     =
  Database     = test
  OPTION       = 3
  SOCKET       = 
@end example


Refer to the @ref{Connection parameters}, for the list of connection parameters that can be supplied

@strong{Note}, if you are using unixODBC, then you can make use of the 
following tools in order to setup the DSN:
@itemize
@item ODBCConfig GUI tool(
@uref{http://www.unixodbc.org/config.html, HOWTO : ODBCConfig})
@item odbcinst
@end itemize


@node Connection parameters ,  , Configuring Connector/ODBC DSN , Developing Applications Using Connector/ODBC
@section Connection parameters 

One can specify the following parameters for @strong{Connector/ODBC} or
@strong{Connector/ODBC 3.51} on the @code{[Data Source Name]} section of an
@code{ODBC.INI} file or through the @code{InConnectionString}
argument in the @code{SQLDriverConnect()} call.

@multitable @columnfractions .2 .2 .6
@item @strong{Parameter} @tab @strong{Default value} @tab @strong{Comment}
@item user @tab ODBC (on Windows) @tab The username used to connect to MySQL.
@item server @tab localhost @tab The hostname of the MySQL server.
@item database @tab @tab The default database
@item option @tab 0 @tab A integer by which you can specify how @strong{Connector/ODBC 3.51} should work. See below.
@item port @tab 3306 @tab The TCP/IP port to use if @code{server} is not @code{localhost}.
@item stmt @tab @tab A statement that will be executed when connection to @code{MySQL}.
@item password @tab @tab The password for the @code{server} @code{user} combination.
@item socket @tab @tab The socket or Windows pipe to connect to.
@end multitable

The @code{OPTION} argument is used to tell @strong{Connector/ODBC 3.51} that the
client isn't 100% ODBC compliant. On Windows, one normally sets the
option flag by toggling the different options on the connection screen
but one can also set this using @code{OPTION} connection argument. 
The following options are listed in the same order as they appear in 
the @strong{Connector/ODBC 3.51} connect screen:

@multitable @columnfractions .1 .9
@item @strong{Bit} @tab @strong{Description}
@item 1 @tab The client can't handle that @strong{Connector/ODBC} returns the real width of a column.
@item 2 @tab  The client can't handle that MySQL returns the true value of affected rows.  If this flag is set then MySQL returns 'found rows' instead.  One must have MySQL 3.21.14 or newer to get this to work.
@item 4 @tab Make a debug log in @file{c:\myodbc.log}(@file{/tmp/myodbc.log}). This is the same as putting @code{MYSQL_DEBUG=d:t:O,c::\myodbc.log} in @file{AUTOEXEC.BAT}
@item 8  @tab Don't set any packet limit for results and parameters.
@item 16 @tab Don't prompt for questions even if driver would like to prompt
@item 32 @tab Enable or disable the dynamic cursor support. This is not allowed in Connector/ODBC 2.50.
@item 64 @tab Ignore use of database name in 'database.table.column'.
@item 128 @tab Force use of ODBC manager cursors (experimental).
@item 256 @tab Disable the use of extended fetch (experimental).
@item 512 @tab Pad CHAR fields to full column length.
@item 1024 @tab SQLDescribeCol() will return fully qualified column names
@item 2048 @tab Use the compressed server/client protocol
@item 4096 @tab Tell server to ignore space after function name and before @code{'('} (needed by Power Builder). This will make all function names keywords!
@item 8192 @tab Connect with named pipes to a @code{mysqld} server running on NT.
@item 16384 @tab Change LONGLONG columns to INT columns (some applications can't handle LONGLONG).
@item 32768 @tab Return 'user' as Table_qualifier and Table_owner from SQLTables (experimental)
@item 65536 @tab Read parameters from the @code{client} and @code{odbc} groups from @file{my.cnf}
@item 131072 @tab Add some extra safety checks (should not bee needed but...)
@item 262144 @tab Disable transactions
@item 524288 @tab Enable query logging to @file{c:\myodbc.sql}(@file{/tmp/myodbc.sql})
file - enabled only in debug mode
@item 1048576 @tab Do not cache the results locally in the driver,
instead read from server(@code{mysql_use_result}). This works only for
forward-only cursors. This option is very important in dealing 
with large tables when one doesn't want the driver to cache the 
entire resultset.
@item 2097152 @tab Force the use of @code{'Forward-only'} cursor type. In case
of applications setting the deafult static/dynamic cursor type, and one
wants driver to use non-cache resultsets, then this option will ensure
the forward-only cursor behaviour.
@end multitable

If you want to have many options, you should add the above flags.  For
example setting option to 12 (4+8) gives you debugging without package
limits.

The default @file{MYODBC3.DLL} is compiled for optimal performance.  If
you want to to debug @code{Connector/ODBC 3.51} (for example to enable tracing),
you should instead use @code{MYODBCD3.DLL}.  To install this file, copy
@file{MYODBCD3.DLL} over the installed @code{MYODBC3.DLL} file.



@c
@c Chapter 4
@c


@node Connector/ODBC API Reference, Connector/ODBC Data Types, Developing Applications Using Connector/ODBC, Top
@chapter Connector/ODBC API Reference

This chapter summarized ODBC routines, categorized by their functionality.

For the complete ODBC API reference, please refer to the
@uref{http://msdn.microsoft.com/library/en-us/odbc/htm/odintropr.asp,ODBC Programmer's Reference}.

@menu
* Connector/ODBC Function summary::  Connector/ODBC Function Summary
@end menu


@node Connector/ODBC Function summary,  , Connector/ODBC API Reference, Connector/ODBC API Reference
@section Connector/ODBC Function Summary


An application can call SQLGetInfo function to obtain conformance 
information about Connector/ODBC. To obtain information about support for a specific 
function in the driver, an application can call SQLGetFunctions.
  
Note Connector/ODBC 3.51 driver for backward compatibility supports all deprecated 
functions.
  
Here is the list of Connector/ODBC APIs grouped together based on the tasks:

@multitable @columnfractions .5 .5 .5 .5 .5 .6
@item @strong{Task} @tab @strong{Function name} @tab @strong{Connector/ODBC} @tab @strong{Connector/ODBC 3.51} @tab @strong{Conformance} @tab @strong{Purpose}

@item Connecting to a data source 
      @tab SQLAllocHandle @tab No @tab Yes @tab ISO 92 @tab Obtains an  environment, connection, statement, or descriptor handle. 
@item @tab SQLConnect @tab Yes @tab Yes @tab ISO 92 @tab Connects to a specific driver by data source name, user ID, 
      and password. 
@item @tab SQLDriverConnect @tab Yes  @tab Yes @tab ODBC @tab Connects to a specific driver by connection string or requests that the Driver Manager and driver display connection dialog boxes for the user. 
@item @tab SQLAllocEnv @tab Yes @tab Yes @tab Deprecated @tab Obtains an environment handle allocated from driver.    
@item @tab SQLAllocConnect @tab Yes @tab Yes @tab Deprecated @tab Obtains a connection handle 


@item Obtaining information about a driver and data source 
      @tab SQLDataSources @tab No @tab No @tab ISO 92 @tab Returns the list of available data sources, handled by the Driver Manager
@item @tab SQLDrivers @tab No @tab No @tab ODBC @tab Returns the list of installed drivers and their attributes, handles by Driver Manager
@item @tab SQLGetInfo @tab Yes @tab Yes @tab ISO 92 @tab Returns information about a specific driver and data source. 
@item @tab SQLGetFunctions @tab Yes @tab Yes @tab ISO 92 @tab Returns supported driver functions. 
@item @tab SQLGetTypeInfo @tab Yes @tab Yes @tab ISO 92 @tab Returns information about supported data types. 


@item Setting and retrieving driver attributes 
      @tab SQLSetConnectAttr @tab No @tab Yes @tab ISO 92 @tab Sets a connection attribute.
@item @tab SQLGetConnectAttr @tab No @tab Yes @tab ISO 92 @tab Returns the value of a connection attribute.
@item @tab SQLSetConnectOption @tab Yes @tab Yes @tab Deprecated @tab Sets a connection option
@item @tab SQLGetConnectOption @tab Yes @tab Yes @tab Deprecated @tab Returns the value of a connection option
@item @tab SQLSetEnvAttr @tab No @tab Yes @tab ISO 92 @tab Sets an environment attribute. 
@item @tab SQLGetEnvAttr @tab No @tab Yes @tab ISO 92 @tab  Returns the value of an environment attribute. 
@item @tab SQLSetStmtAttr @tab No @tab Yes @tab ISO 92 @tab Sets a statement attribute. 
@item @tab SQLGetStmtAttr @tab No @tab Yes @tab ISO 92 @tab Returns the value of a statement attribute. 
@item @tab SQLSetStmtOption @tab Yes @tab Yes @tab Deprecated @tab Sets a statement option
@item @tab SQLGetStmtOption @tab Yes @tab Yes @tab Deprecated @tab Returns the value of a statement option 


@item Preparing SQL requests 
      @tab SQLAllocStmt @tab Yes @tab Yes @tab Deprecated @tab Allocates a statement handle
@item @tab SQLPrepare @tab Yes @tab Yes @tab ISO 92 @tab Prepares an SQL statement for later execution. 
@item @tab SQLBindParameter @tab Yes @tab Yes @tab ODBC @tab Assigns storage for a parameter in an SQL statement. 
@item @tab SQLGetCursorName @tab  Yes @tab Yes @tab ISO 92 @tab Returns the cursor name associated with a statement handle. 
@item @tab SQLSetCursorName @tab Yes @tab Yes @tab ISO 92 @tab Specifies a cursor name. 
@item @tab SQLSetScrollOptions @tab Yes @tab Yes @tab ODBC @tab Sets options that control cursor behavior.

 
@item submitting requests 
      @tab SQLExecute @tab Yes @tab Yes @tab ISO 92 @tab Executes a prepared statement.
@item @tab SQLExecDirect @tab Yes @tab Yes @tab ISO 92 @tab Executes a statement
@item @tab SQLNativeSql @tab Yes @tab Yes @tab ODBC @tab Returns the text of an SQL statement as translated by the driver. 
@item @tab SQLDescribeParam @tab Yes @tab Yes @tab ODBC @tab Returns the description for a specific parameter in a statement. 
@item @tab SQLNumParams @tab Yes @tab Yes @tab ISO 92 @tab Returns the number of parameters in a statement. 
@item @tab SQLParamData @tab Yes @tab Yes @tab ISO 92 @tab Used in conjunction with SQLPutData to supply parameter data at execution time. (Useful for long data values.) 
@item @tab SQLPutData @tab Yes @tab Yes @tab ISO 92 @tab Sends part or all of a data value for a parameter. (Useful for long data values.) 


@item Retrieving results and information about results 
      @tab SQLRowCount @tab Yes @tab Yes @tab ISO 92 @tab Returns the number of rows affected by an insert, update, or delete request.
@item @tab SQLNumResultCols @tab Yes @tab Yes @tab ISO 92 @tab Returns the number of columns in the result set.
@item @tab SQLDescribeCol @tab  Yes @tab Yes @tab ISO 92  @tab Describes a column in the result set. 
@item @tab SQLColAttribute @tab No @tab Yes @tab ISO 92 @tab Describes attributes of a column in the result set. 
@item @tab SQLColAttributes  @tab Yes @tab Yes @tab Deprecated @tab  Describes attributes of a column in the result set. 
@item @tab SQLFetch @tab Yes @tab Yes @tab ISO 92 @tab  Returns multiple result rows. 
@item @tab SQLFetchScroll @tab No @tab Yes @tab ISO 92  @tab Returns scrollable result rows. 
@item @tab SQLExtendedFetch  @tab Yes @tab Yes @tab Deprecated  @tab Returns scrollable result rows. 
@item @tab SQLSetPos @tab Yes @tab Yes @tab ODBC @tab Positions a cursor within a fetched block of data and allows an application to refresh data in the rowset or to update or delete data  in the result set. 
@item @tab  SQLBulkOperations @tab No  @tab Yes @tab ODBC @tab  Performs bulk insertions and bulk bookmark operations, including update, delete, and fetch by bookmark. 


@item Retrieving error or diagnostic information 
      @tab SQLError @tab Yes @tab Yes @tab Deprecated  @tab Returns additional error or status information 
@item @tab SQLGetDiagField @tab Yes @tab Yes @tab ISO 92  @tab Returns additional diagnostic information (a single field of the diagnostic data structure). 
@item @tab SQLGetDiagRec @tab Yes @tab Yes @tab ISO 92 @tab  Returns additional diagnostic information (multiple fields of the diagnostic data structure). 


@item Obtaining information about the data source's system tables (catalog functions) item 
      @tab SQLColumnPrivileges @tab Yes @tab Yes @tab ODBC @tab Returns a list of columns and associated privileges for one or more tables.
@item @tab SQLColumns @tab Yes @tab Yes @tab X/Open @tab Returns the list of column names in specified tables.
@item @tab SQLForeignKeys @tab Yes @tab Yes @tab ODBC  @tab Returns a list of column names that make up foreign keys, if they exist for a specified table. 
@item @tab SQLPrimaryKeys @tab Yes @tab Yes @tab ODBC  @tab Returns the list of column names that make up the primary key for a table. 
@item @tab SQLSpecialColumns @tab Yes @tab Yes @tab X/Open  @tab Returns information about the optimal set of columns that uniquely identifies a row in a specified table, or the columns that are automatically updated when any value in the row is updated by a 
      transaction. 
@item @tab SQLStatistics @tab Yes @tab Yes @tab ISO 92 @tab Returns statistics about a single table and the list of indexes associated with the table. 
@item @tab SQLTablePrivileges  @tab Yes @tab Yes @tab ODBC @tab  Returns a list of tables and the privileges associated with each table. 
@item @tab SQLTables  @tab Yes @tab Yes @tab X/Open  @tab Returns the list of table names stored in a specific data source. 


@item Performing Transactions 
      @tab SQLTransact @tab Yes @tab Yes @tab Deprecated @tab Commits or rolls back a transaction  
@item @tab  SQLEndTran  @tab No  @tab Yes @tab ISO 92  @tab Commits or rolls back a transaction. 


@item Terminating a statement 
       @tab SQLFreeStmt @tab Yes @tab Yes @tab ISO 92 @tab  Ends statement processing, discards pending results, and, optionally, frees all resources associated with the statement handle. 
@item @tab SQLCloseCursor  @tab Yes @tab Yes @tab ISO 92  @tab Closes a cursor that has been opened on a statement handle. 
@item @tab SQLCancel  @tab Yes @tab Yes @tab ISO 92  @tab Cancels an SQL statement. 


@item Terminating a connection 
      @tab SQLDisconnect @tab Yes @tab Yes @tab ISO 92 @tab Closes the connection. 
@item @tab SQLFreeHandle @tab No  @tab Yes @tab ISO 92 @tab Releases an environment, connection, statement, or descriptor handle.
@item @tab SQLFreeConnect @tab Yes @tab Yes @tab Deprecated @tab Releases connection handle
@item @tab SQLFreeEnv @tab Yes @tab Yes @tab Deprecated @tab Releases an environment handle

@end multitable


@c
@c APPENDIX - A
@c


@node Connector/ODBC Data Types, Connector/ODBC Error Codes, Connector/ODBC API Reference, Top
@appendix Connector/ODBC Data Types

The following table illustrates how driver maps the server data types to default 
SQL and C data types:

@multitable @columnfractions .2 .2 .9
@item @strong{Native Value} @tab @strong{SQL Type} @tab @strong{C Type}

@item  bit @tab SQL_BIT @tab SQL_C_BIT
@item  tinyint @tab SQL_TINYINT @tab SQL_C_STINYINT
@item  tinyint unsigned @tab SQL_TINYINT @tab SQL_C_UTINYINT
@item  bigint  @tab SQL_BIGINT @tab SQL_C_SBIGINT
@item  bigint unsigned @tab SQL_BIGINT @tab SQL_C_UBIGINT
@item  long varbinary @tab SQL_LONGVARBINARY @tab SQL_C_BINARY
@item  blob @tab SQL_VARBINARY @tab SQL_C_BINARY
@item  longblob @tab SQL_VARBINARY @tab SQL_C_BINARY
@item  tinyblob @tab SQL_BINARY @tab SQL_C_BINARY
@item  mediumblob @tab SQL_LONGVARBINARY @tab SQL_C_BINARY
@item  long varchar @tab SQL_LONGVARCHAR @tab SQL_C_CHAR
@item  text @tab SQL_LONGVARCHAR @tab SQL_C_CHAR
@item  mediumtext @tab SQL_LONGVARCHAR @tab SQL_C_CHAR
@item  char @tab SQL_CHAR @tab SQL_C_CHAR
@item  numeric @tab SQL_NUMERIC @tab SQL_C_CHAR
@item  decimal @tab SQL_DECIMAL @tab SQL_C_CHAR
@item  integer @tab SQL_INTEGER @tab SQL_C_SLONG
@item  integer unsigned @tab SQL_INTEGER @tab SQL_C_ULONG
@item  int @tab SQL_INTEGER @tab SQL_C_SLONG
@item  int unsigned @tab SQL_INTEGER @tab SQL_C_ULONG
@item  mediumint @tab SQL_INTEGER @tab SQL_C_SLONG
@item  mediumint unsigned @tab SQL_INTEGER @tab SQL_C_ULONG
@item  smallint @tab SQL_SMALLINT @tab SQL_C_SSHORT
@item  smallint unsigned @tab SQL_SMALLINT @tab SQL_C_USHORT
@item  real @tab SQL_FLOAT @tab SQL_C_DOUBLE
@item  double @tab SQL_FLOAT @tab SQL_C_DOUBLE
@item  float @tab SQL_REAL @tab SQL_C_FLOAT
@item  double prec @tab SQL_DOUBLE @tab SQL_C_DOUBLE
@item  date @tab SQL_DATE @tab SQL_C_DATE
@item  time @tab SQL_TIME @tab SQL_C_TIME
@item  year @tab SQL_SMALLINT @tab SQL_C_SHORT
@item  datetime @tab SQL_TIMESTAMP @tab SQL_C_TIMESTAMP
@item  timestamp @tab SQL_TIMESTAMP @tab SQL_C_TIMESTAMP
@item  text @tab SQL_VARCHAR @tab SQL_C_CHAR
@item  varchar @tab SQL_VARCHAR @tab SQL_C_CHAR
@item  enum @tab SQL_VARCHAR @tab SQL_C_CHAR
@item  set @tab SQL_VARCHAR @tab SQL_C_CHAR
@item  bit @tab SQL_CHAR @tab SQL_C_CHAR
@item  bool @tab SQL_CHAR @tab SQL_C_CHAR
@end multitable


@c
@c APPENDIX - C
@c

@node Connector/ODBC Error Codes, Connector/ODBC With VB, Connector/ODBC Data Types, Top
@appendix Connector/ODBC Error Codes

The following tables lists the error codes returned by the driver apart 
from the server errors.

@multitable @columnfractions .1 .1 .1 .2
@item @strong{NATIVE CODE} @tab @strong{SQLSTATE 2} @tab @strong{SQLSTATE 3} @tab @strong{ERROR MESSAGE}
@item 500 @tab 01000 @tab 01000 @tab General warning
@item 501 @tab 01004 @tab 01004 @tab String data, right truncated
@item 502 @tab 01S02 @tab 01S02 @tab Option value changed
@item 503 @tab 01S03 @tab 01S03 @tab No rows updated/deleted
@item 504 @tab 01S04 @tab 01S04 @tab More than one row updated/deleted
@item 505 @tab 01S06 @tab 01S06 @tab Attempt to fetch before the result set returned the first row set
@item 506 @tab 07001 @tab 07002 @tab SQLBindParameter not used for all parameters
@item 507 @tab 07005 @tab 07005 @tab Prepared statement not a cursor-specification
@item 508 @tab 07009 @tab 07009 @tab Invalid descriptor index
@item 509 @tab 08002 @tab 08002 @tab Connection name in use
@item 510 @tab 08003 @tab 08003 @tab Connection does not exist
@item 511 @tab 24000 @tab 24000 @tab Invalid cursor state
@item 512 @tab 25000 @tab 25000 @tab Invalid transaction state
@item 513 @tab 25S01 @tab 25S01 @tab Transaction state unknown
@item 514 @tab 34000 @tab 34000 @tab Invalid cursor name
@item 515 @tab S1000 @tab HY000 @tab General driver defined error
@item 516 @tab S1001 @tab HY001 @tab Memory allocation error
@item 517 @tab S1002 @tab HY002 @tab Invalid column number
@item 518 @tab S1003 @tab HY003 @tab Invalid application buffer type
@item 519 @tab S1004 @tab HY004 @tab Invalid SQL data type
@item 520 @tab S1009 @tab HY009 @tab Invalid use of null pointer
@item 521 @tab S1010 @tab HY010 @tab Function sequence error
@item 522 @tab S1011 @tab HY011 @tab Attribute can not be set now
@item 523 @tab S1012 @tab HY012 @tab Invalid transaction operation code
@item 524 @tab S1013 @tab HY013 @tab Memory management error
@item 525 @tab S1015 @tab HY015 @tab No cursor name available
@item 526 @tab S1024 @tab HY024 @tab Invalid attribute value
@item 527 @tab S1090 @tab HY090 @tab Invalid string or buffer length
@item 528 @tab S1091 @tab HY091 @tab Invalid descriptor field identifier
@item 529 @tab S1092 @tab HY092 @tab Invalid attribute/option identifier
@item 530 @tab S1093 @tab HY093 @tab Invalid parameter number
@item 531 @tab S1095 @tab HY095 @tab Function type out of range
@item 532 @tab S1106 @tab HY106 @tab Fetch type out of range
@item 533 @tab S1117 @tab HY117 @tab Row value out of range
@item 534 @tab S1109 @tab HY109 @tab Invalid cursor position
@item 535 @tab S1C00 @tab HYC00 @tab Optional feature not implemented
@item 0 @tab 21S01 @tab 21S01 @tab Column count does not match value count
@item 0 @tab 23000 @tab 23000 @tab Integrity constraint violation
@item 0 @tab 42000 @tab 42000 @tab Syntax error or access violation
@item 0 @tab 42S02 @tab 42S02 @tab Base table or view not found
@item 0 @tab 42S12 @tab 42S12 @tab Index not found
@item 0 @tab 42S21 @tab 42S21 @tab Column already exists
@item 0 @tab 42S22 @tab 42S22 @tab Column not found
@item 0 @tab 08S01 @tab 08S01 @tab Communication link failure
@end multitable



@c
@c APPENIX - D
@c


@node Connector/ODBC With VB, Connector/ODBC With .NET, Connector/ODBC Error Codes, Top
@appendix Connector/ODBC With VB - ADO, DAO and RDO


This chapter contains simple samples on the usage of MySQL ODBC 3.51 Driver with ADO, DAO and RDO.

@menu
* ADO - rs.addNew::             ADO - rs.addNew, rs.delete and rs.update
* DAO - rs.addNew::             DAO - rs.addNew, rs.update and scrolling
* RDO - rs.addNew and rs.update ::  RDO - rs.addNew and rs.update
@end menu

@node ADO - rs.addNew, DAO - rs.addNew, Connector/ODBC With VB, Connector/ODBC With VB
@appendixsec ADO - rs.addNew, rs.delete and rs.update 


The following @strong{ADO}@code{(ActiveX Data Objects)} sample creates a table 
my_ado and demonstrates the usage of rs.addNew, rs.delete and rs.update.

@example
Private Sub myodbc_ado_Click()
   
  Dim conn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Dim fld As ADODB.Field
  Dim sql As String

  'connect to MySQL server using MySQL ODBC 3.51 Driver
  Set conn = New ADODB.Connection
  conn.ConnectionString = "DRIVER=@{MySQL ODBC 3.51 Driver@};"_
                        & "SERVER=localhost;"_ 
                        & " DATABASE=test;"_
                        & "UID=venu;PWD=venu; OPTION=3"

  conn.Open

  'create table
  conn.Execute "DROP TABLE IF EXISTS my_ado"
  conn.Execute "CREATE TABLE my_ado(id int not null primary key, name varchar(20)," _
                                 & "txt text, dt date, tm time, ts timestamp)"

  'direct insert
  conn.Execute "INSERT INTO my_ado(id,name,txt) values(1,100,'venu')"
  conn.Execute "INSERT INTO my_ado(id,name,txt) values(2,200,'MySQL')"
  conn.Execute "INSERT INTO my_ado(id,name,txt) values(3,300,'Delete')"

  Set rs = New ADODB.Recordset
  rs.CursorLocation = adUseServer

  'fetch the initial table ..
  rs.Open "SELECT * FROM my_ado", conn
    Debug.Print rs.RecordCount
    rs.MoveFirst
    Debug.Print String(50, "-") & "Initial my_ado Result Set " & String(50, "-")
    For Each fld In rs.Fields
      Debug.Print fld.Name,
      Next
      Debug.Print

      Do Until rs.EOF
      For Each fld In rs.Fields
      Debug.Print fld.Value,
      Next
      rs.MoveNext
      Debug.Print
    Loop
  rs.Close

  'rs insert
  rs.Open "select * from my_ado", conn, adOpenDynamic, adLockOptimistic
  rs.AddNew
  rs!Name = "Monty"
  rs!txt = "Insert row"
  rs.Update
  rs.Close

  'rs update
  rs.Open "SELECT * FROM my_ado"
  rs!Name = "update"
  rs!txt = "updated-row"
  rs.Update
  rs.Close

  'rs update second time..
  rs.Open "SELECT * FROM my_ado"
  rs!Name = "update"
  rs!txt = "updated-second-time"
  rs.Update
  rs.Close

  'rs delete
  rs.Open "SELECT * FROM my_ado"
  rs.MoveNext
  rs.MoveNext
  rs.Delete
  rs.Close

  'fetch the updated table ..
  rs.Open "SELECT * FROM my_ado", conn
    Debug.Print rs.RecordCount
    rs.MoveFirst
    Debug.Print String(50, "-") & "Updated my_ado Result Set " & String(50, "-")
    For Each fld In rs.Fields
      Debug.Print fld.Name,
      Next
      Debug.Print

      Do Until rs.EOF
      For Each fld In rs.Fields
      Debug.Print fld.Value,
      Next
      rs.MoveNext
      Debug.Print
    Loop
  rs.Close
  conn.Close
End Sub
@end example


@node DAO - rs.addNew, RDO - rs.addNew and rs.update , ADO - rs.addNew, Connector/ODBC With VB
@appendixsec DAO - rs.addNew, rs.update and scrolling 


The following @strong{DAO} @code{(Data Access Objects)} sample creates a 
table my_dao and demonstrates the usage of rs.addNew, rs.update, and 
result set scrolling.

@example
Private Sub myodbc_dao_Click()

  Dim ws As Workspace
  Dim conn As Connection
  Dim queryDef As queryDef
  Dim str As String

  'connect to MySQL using MySQL ODBC 3.51 Driver
  Set ws = DBEngine.CreateWorkspace("", "venu", "venu", dbUseODBC)
  str = "odbc;DRIVER=@{MySQL ODBC 3.51 Driver@};"_
                        & "SERVER=localhost;"_ 
                        & " DATABASE=test;"_
                        & "UID=venu;PWD=venu; OPTION=3"
  Set conn = ws.OpenConnection("test", dbDriverNoPrompt, False, str)

  'Create table my_dao
  Set queryDef = conn.CreateQueryDef("", "drop table if exists my_dao")
  queryDef.Execute

  Set queryDef = conn.CreateQueryDef("", "create table my_dao(Id INT AUTO_INCREMENT PRIMARY KEY, " _
                                                           & "Ts TIMESTAMP(14) NOT NULL, Name varchar(20), Id2 INT)")
  queryDef.Execute

  'Insert new records using rs.addNew
  Set rs = conn.OpenRecordset("my_dao")
  Dim i As Integer

    For i = 10 To 15
    rs.AddNew
    rs!Name = "insert record" & i
    rs!Id2 = i
    rs.Update
    Next i
             rs.Close

  'rs update..
  Set rs = conn.OpenRecordset("my_dao")
  rs.Edit
  rs!Name = "updated-string"
  rs.Update
  rs.Close

  'fetch the table back...
  Set rs = conn.OpenRecordset("my_dao", dbOpenDynamic)
  str = "Results:"
  rs.MoveFirst
  While Not rs.EOF
  str = " " & rs!Id & " , " & rs!Name & ", " & rs!Ts & ", " & rs!Id2
  Debug.Print "DATA:" & str
  rs.MoveNext
  Wend

  'rs Scrolling
  rs.MoveFirst
  str = " FIRST ROW: " & rs!Id & " , " & rs!Name & ", " & rs!Ts & ", " & rs!Id2
  Debug.Print str

  rs.MoveLast
  str = " LAST ROW: " & rs!Id & " , " & rs!Name & ", " & rs!Ts & ", " & rs!Id2
  Debug.Print str

  rs.MovePrevious
  str = " LAST-1 ROW: " & rs!Id & " , " & rs!Name & ", " & rs!Ts & ", " & rs!Id2
  Debug.Print str

  'free all resources
  rs.Close
  queryDef.Close
  conn.Close
  ws.Close
   
End Sub
@end example


@node RDO - rs.addNew and rs.update ,  , DAO - rs.addNew, Connector/ODBC With VB
@appendixsec RDO - rs.addNew and rs.update 


The following @strong{RDO} @code{(Remote Data Objects)} sample creates a table 
my_rdo and demonstrates the usage of rs.addNew and rs.update.

@example
Dim rs As rdoResultset
    Dim cn As New rdoConnection
    Dim cl As rdoColumn
    Dim SQL As String

    'cn.Connect = "DSN=test;"
    cn.Connect = "DRIVER=@{MySQL ODBC 3.51 Driver@};"_
                        & "SERVER=localhost;"_ 
                        & " DATABASE=test;"_
                        & "UID=venu;PWD=venu; OPTION=3"

    cn.CursorDriver = rdUseOdbc
    cn.EstablishConnection rdDriverPrompt


    'drop table my_rdo
    SQL = "drop table if exists my_rdo"
    cn.Execute SQL, rdExecDirect

    'create table my_rdo
    SQL = "create table my_rdo(id int, name varchar(20))"
    cn.Execute SQL, rdExecDirect

    'insert - direct
    SQL = "insert into my_rdo values (100,'venu')"
    cn.Execute SQL, rdExecDirect

    SQL = "insert into my_rdo values (200,'MySQL')"
    cn.Execute SQL, rdExecDirect

    'rs insert
    SQL = "select * from my_rdo"
    Set rs = cn.OpenResultset(SQL, rdOpenStatic, rdConcurRowVer, rdExecDirect)
    rs.AddNew
    rs!id = 300
    rs!Name = "Insert1"
    rs.Update
    rs.Close

    'rs insert
    SQL = "select * from my_rdo"
    Set rs = cn.OpenResultset(SQL, rdOpenStatic, rdConcurRowVer, rdExecDirect)
    rs.AddNew
    rs!id = 400
    rs!Name = "Insert 2"
    rs.Update
    rs.Close

    'rs update
    SQL = "select * from my_rdo"
    Set rs = cn.OpenResultset(SQL, rdOpenStatic, rdConcurRowVer, rdExecDirect)
    rs.Edit
    rs!id = 999
    rs!Name = "updated"
    rs.Update
    rs.Close 

    'fetch back...
    SQL = "select * from my_rdo"
    Set rs = cn.OpenResultset(SQL, rdOpenStatic, rdConcurRowVer, rdExecDirect)
    Do Until rs.EOF
    For Each cl In rs.rdoColumns
                Debug.Print cl.Value,
      Next
      rs.MoveNext
      Debug.Print
               Loop
    Debug.Print "Row count="; rs.RowCount

    'close
    rs.Close
    cn.Close
   
End Sub
@end example


@c 
@c APPENDIX - D
@c 

@node Connector/ODBC With .NET, Credits, Connector/ODBC With VB, Top
@appendix Connector/ODBC with Microsoft .NET

This chapter contains simple samples to demonstrate the usage 
of Connector/ODBC drivers with ODBC.NET

@menu
* ODBC.NET(C#)::                ODBC.NET - CSHARP(C#)
* ODBC.NET(VB)::                ODBC.NET - VB
@end menu

@node ODBC.NET(C#), ODBC.NET(VB), Connector/ODBC With .NET, Connector/ODBC With .NET
@appendixsec ODBC.NET - CSHARP(C#)


The following sample creates a table my_odbc_net and 
demonstrates the usage in C#.

@example

 /**
 * @@sample    : mycon.cs
 * @@purpose   : Demo sample for ODBC.NET using Connector/ODBC
 * @@author    : Venu, @email{venu@@mysql.com}
 *
 * (C) Copyright MySQL AB, 1995-2003
 *
 **/

 /* build command
  * 
  *  csc /t:exe 
  *      /out:mycon.exe mycon.cs 
  *      /r:Microsoft.Data.Odbc.dll 
  */ 

 using Console = System.Console;
 using Microsoft.Data.Odbc;

 namespace myodbc3
 @{
  class mycon
  @{
    static void Main(string[] args)
    @{
      try
      @{ 
        //Connection string for Connector/ODBC 2.50
        /*string MyConString = "DRIVER=@{MySQL@};" + 
                             "SERVER=localhost;" +
                             "DATABASE=test;" +
                             "UID=venu;" +
                             "PASSWORD=venu;" +
                             "OPTION=3";
        */
        //Connection string for Connector/ODBC 3.51
        string MyConString = "DRIVER=@{MySQL ODBC 3.51 Driver@};" + 
                             "SERVER=localhost;" +
                             "DATABASE=test;" +
                             "UID=venu;" +
                             "PASSWORD=venu;" +
                             "OPTION=3";
                    
        //Connect to MySQL using Connector/ODBC
        OdbcConnection MyConnection = new OdbcConnection(MyConString);    
        MyConnection.Open();
  
        Console.WriteLine("\n !!! success, connected successfully !!!\n");    

        //Display connection information
        Console.WriteLine("Connection Information:");   
        Console.WriteLine("\tConnection String:" + MyConnection.ConnectionString);    
        Console.WriteLine("\tConnection Timeout:" + MyConnection.ConnectionTimeout);    
        Console.WriteLine("\tDatabase:" + MyConnection.Database);   
        Console.WriteLine("\tDataSource:" + MyConnection.DataSource);
        Console.WriteLine("\tDriver:" + MyConnection.Driver);
        Console.WriteLine("\tServerVersion:" + MyConnection.ServerVersion);

        //Create a sample table
        OdbcCommand MyCommand = new OdbcCommand("DROP TABLE IF EXISTS my_odbc_net",MyConnection);
        MyCommand.ExecuteNonQuery();
        MyCommand.CommandText = "CREATE TABLE my_odbc_net(id int, name varchar(20), idb bigint)";
        MyCommand.ExecuteNonQuery();

        //Insert
        MyCommand.CommandText = "INSERT INTO my_odbc_net VALUES(10,'venu', 300)";        
        Console.WriteLine("INSERT, Total rows affected:" + MyCommand.ExecuteNonQuery());;

        //Insert
        MyCommand.CommandText = "INSERT INTO my_odbc_net VALUES(20,'mysql',400)";        
        Console.WriteLine("INSERT, Total rows affected:" + MyCommand.ExecuteNonQuery());

        //Insert
        MyCommand.CommandText = "INSERT INTO my_odbc_net VALUES(20,'mysql',500)";        
        Console.WriteLine("INSERT, Total rows affected:" + MyCommand.ExecuteNonQuery());

        //Update
        MyCommand.CommandText = "UPDATE my_odbc_net SET id=999 WHERE id=20";        
        Console.WriteLine("Update, Total rows affected:" + MyCommand.ExecuteNonQuery());

        //COUNT(*)        
        MyCommand.CommandText = "SELECT COUNT(*) as TRows FROM my_odbc_net";        
        Console.WriteLine("Total Rows:" + MyCommand.ExecuteScalar());

        //Fetch
        MyCommand.CommandText = "SELECT * FROM my_odbc_net";                
        OdbcDataReader MyDataReader;
        MyDataReader =  MyCommand.ExecuteReader();
        while (MyDataReader.Read())
        @{
         if(string.Compare(MyConnection.Driver,"myodbc3.dll") == 0) @{
           Console.WriteLine("Data:" + MyDataReader.GetInt32(0) + " " +
                                       MyDataReader.GetString(1) + " " +
                                       MyDataReader.GetInt64(2)); //Supported only by Connector/ODBC 3.51
         @}
         else @{            
           Console.WriteLine("Data:" + MyDataReader.GetInt32(0) + " " +
                                       MyDataReader.GetString(1) + " " +                                         
                                       MyDataReader.GetInt32(2)); //BIGINTs not supported by Connector/ODBC
         @}
        @}

        //Close all resources
        MyDataReader.Close();
        MyConnection.Close();
      @}
      catch (OdbcException MyOdbcException)//Catch any ODBC exception ..
      @{
        for (int i=0; i < MyOdbcException.Errors.Count; i++)
        @{
          Console.Write("ERROR #" + i + "\n" +
            "Message: " + MyOdbcException.Errors[i].Message + "\n" +
            "Native: " + MyOdbcException.Errors[i].NativeError.ToString() + "\n" +
            "Source: " + MyOdbcException.Errors[i].Source + "\n" +
            "SQL: " + MyOdbcException.Errors[i].SQLState + "\n");
        @}
      @}
    @}
  @}
 @}
@end example

@node ODBC.NET(VB),  , ODBC.NET(C#), Connector/ODBC With .NET
@appendixsec ODBC.NET - VB


The following sample creates a table my_vb_net and 
demonstrates the usage in VB.

@example
' @@sample    : myvb.vb
' @@purpose   : Demo sample for ODBC.NET using Connector/ODBC
' @@author    : Venu, @email{venu@@mysql.com}
'
' (C) Copyright MySQL AB, 1995-2003
'
'

' 
' build command
'
' vbc /target:exe 
'     /out:myvb.exe 
'     /r:Microsoft.Data.Odbc.dll 
'     /r:System.dll 
'     /r:System.Data.dll 
'
 
Imports Microsoft.Data.Odbc
Imports System

Module myvb
    Sub Main()
        Try

            'Connector/ODBC 3.51 connection string
            Dim MyConString As String = "DRIVER=@{MySQL ODBC 3.51 Driver@};" & _
                           "SERVER=localhost;" & _
                           "DATABASE=test;" & _
                           "UID=venu;" & _
                           "PASSWORD=venu;" & _
                           "OPTION=3;"

            'Connection
            Dim MyConnection As New OdbcConnection(MyConString)
            MyConnection.Open()

            Console.WriteLine ("Connection State::" & MyConnection.State.ToString)
            
            'Drop
            Console.WriteLine ("Dropping table")
            Dim MyCommand As New OdbcCommand()
            MyCommand.Connection = MyConnection
            MyCommand.CommandText = "DROP TABLE IF EXISTS my_vb_net"
            MyCommand.ExecuteNonQuery()
            
            'Create
            Console.WriteLine ("Creating....")
            MyCommand.CommandText = "CREATE TABLE my_vb_net(id int, name varchar(30))"
            MyCommand.ExecuteNonQuery()
            
            'Insert
            MyCommand.CommandText = "INSERT INTO my_vb_net VALUES(10,'venu')"    
            Console.WriteLine("INSERT, Total rows affected:" & MyCommand.ExecuteNonQuery())

            'Insert
            MyCommand.CommandText = "INSERT INTO my_vb_net VALUES(20,'mysql')"
            Console.WriteLine("INSERT, Total rows affected:" & MyCommand.ExecuteNonQuery())

            'Insert
            MyCommand.CommandText = "INSERT INTO my_vb_net VALUES(20,'mysql')"
            Console.WriteLine("INSERT, Total rows affected:" & MyCommand.ExecuteNonQuery())

            'Insert
            MyCommand.CommandText = "INSERT INTO my_vb_net(id) VALUES(30)"
            Console.WriteLine("INSERT, Total rows affected:" & MyCommand.ExecuteNonQuery())

            'Update
            MyCommand.CommandText = "UPDATE my_vb_net SET id=999 WHERE id=20"
            Console.WriteLine("Update, Total rows affected:" & MyCommand.ExecuteNonQuery())

            'COUNT(*)        
            MyCommand.CommandText = "SELECT COUNT(*) as TRows FROM my_vb_net"
            Console.WriteLine("Total Rows:" & MyCommand.ExecuteScalar())

            'Select              
            Console.WriteLine ("Select * FROM my_vb_net")
            MyCommand.CommandText = "SELECT * FROM my_vb_net"
            Dim MyDataReader As OdbcDataReader
            MyDataReader = MyCommand.ExecuteReader
            While MyDataReader.Read
                If MyDataReader("name") Is DBNull.Value Then
                    Console.WriteLine ("id = " & CStr(MyDataReader("id")) & "  name = " & _
                      "NULL")
                Else
                    Console.WriteLine ("id = " & CStr(MyDataReader("id")) & "  name = " & _
                                          CStr(MyDataReader("name")))
                End If
            End While
        
        'Catch ODBC Exception
        Catch MyOdbcException As OdbcException 
            Dim i As Integer
            Console.WriteLine (MyOdbcException.ToString)

        'Catch program exception
        Catch MyException As Exception
            Console.WriteLine (MyException.ToString)
    End Try
    End Sub
End Module
@end example

@node Credits,  , Connector/ODBC With .NET, Top
@appendix Credits

These are the developers that are working full time on Connector/ODBC 
and Connector/ODBC 3.51 Drivers from MySQL AB.

@itemize @bullet
@item
Micheal (Monty) Widenius, @email{monty@@mysql.com}
@item
Venu Anuganti, @email{venu@@mysql.com}
@*
@end itemize

@c @node Function Index,  , GPL license, Top
@c @unnumbered Command, type and function index

@c @printindex fn

@page


@c @node Concept Index,  , Function Index, Top
@c @unnumbered Concept Index

@c @printindex cp





@bye