Article View: borland.public.cppbuilder.database.ado
Article #1093Accessing MySQL via ADO
From: Tumurbaatar S.
Date: Thu, 23 Dec 2004 11:27
Date: Thu, 23 Dec 2004 11:27
35 lines
2364 bytes
2364 bytes
My program connects to MySQL 4.1.7 using ADO components.
The connection string points to MyODBC 3.51.10 DSN (Anybody know
MySQL native OLEDB provider?). The table has only 4 fields where one
of them is BLOB. The next code inserts a new record and it raises
EAccessViolation when a command executes. When Execute() is
removed/commented, no error.
int bounds[2] = {0};
cmd->Parameters->ParamByName("id")->Value = PacketID++;
cmd->Parameters->ParamByName("ip")->Value = AnsiString(Buff->ip);
bounds[1] = Buff->size - 1;
Variant bytes = VarArrayCreate(bounds, 1, varByte);
memcpy(bytes.ArrayLock(), Buff->data, Buff->size);
bytes.ArrayUnlock();
cmd->Parameters->ParamByName("data")->AppendChunk(bytes);
cmd->Execute();
table stucture:
CREATE TABLE packets
(
id INT NOT NULL,
ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
ip VARCHAR(15) NOT NULL,
data BLOB NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX packets_ts ON packets (ts);
CREATE INDEX packets_ip ON packets (ip);
P.S. Also, all 3 above parameters returned by TADOCommand are
ftString, Size=25165824, Attributes=paNullable, paLong. Why?
Does it mean that MyODBC and ADO do not understand each other?
Technical Details
Message-ID:
<41caab99@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!proxad.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!demon!194.74.65.66.MISMATCH!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10698b,5756267530e63452,start X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Tumurbaatar S." <nospam_tumur@magicnet.mn> Newsgroups: borland.public.cppbuilder.database.ado Subject: Accessing MySQL via ADO Date: Thu, 23 Dec 2004 19:27:22 +0800 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 202.131.2.6 Message-ID: <41caab99@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1103801241 202.131.2.6 (23 Dec 2004 03:27:21 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!proxad.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!demon!194.74.65.66.MISMATCH!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail