Article View: borland.public.cppbuilder.database.ado
Article #1034Re: MS Access databases and SQL insert
From: Viatcheslav V. Vassiliev
Date: Wed, 15 Dec 2004 21:46
Date: Wed, 15 Dec 2004 21:46
116 lines
5200 bytes
5200 bytes
esace should be escape, i.e. in c '\' becomes '\\'. Set ParamCheck to false.
ADOExpress treats ':' with ParamCheck = true as parameter. And use ExecSQL
as Matt suggested. You may also use TADOCommand, or call
ADOConnection1->Execute().
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Stefano Bonifazi" <stefboombastic@tele2.it> �������/�������� � ��������
���������: news:41c01d2c@newsgroups.borland.com...
> Hi Again!
> I tried to modify my code as You suggested but the same ugly error showed
> :(
>
> My actual code is the following:
>
> DataSource1->DataSet->Active=false;
> ADOConnection1->Connected=false;
> AnsiString sConnessione="Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source="+OpenDialog1->FileName;
> ADOConnection1->ConnectionString=sConnessione;
> ADOConnection1->Connected=true;
> ADODataSet1->CommandText="Select * From MP3TAG";
> DataSource1->DataSet->Active=true;
>
> AnsiString SQLCommand=
>
> "INSERT INTO
> MP3TAG([Titolo],[Artista],[Album],[Genere],[Anno],[Commento],[File]) "
> "VALUES('My Title', 'My Artist', 'My Album', 'My Genre', '1978', 'My
> Comment', 'c:\\test.mp3')";
>
> ADOQuery1->Close();
> ADOQuery1->SQL->Clear();
> ADOQuery1->SQL->Add(SQLCommand);
> ADOQuery1->Open();
>
> What's wrong with that?
>
> Thank You in advance!
> Regards,
> Stefano B.
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> ha scritto nel
> messaggio news:41c008d4@newsgroups.borland.com...
> > Use native OLEDB provider.
> >
> > ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=c:\\temp\\test.mdb";
> >
> > Do not forget to esace characters in string ('c:\test.mp3' >
> > 'c:\\test.mp3'). Enclose column names into [] - ([Title], [Artist] ...
> >
> > //------------------------------------------
> > Regards,
> > Vassiliev V. V.
> > http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
> > ADO.Net
> > http://www.oledbdirect.com - The fastest way to access MS SQL Server,
> > MS Jet (Access) and Interbase (through OLEDB)
> >
> > "Stefano Bonifazi" <stefboombastic@tele2.it> �������/�������� � ��������
> > ���������: news:41bf77e4@newsgroups.borland.com...
> >> Hi All!!
> >> I'm using an simple test MS Access database.
> >> I connect to the db through a TADOConnection with a connection string:
> >> "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Database di
> >> Microsoft Access;Initial Catalog="+Mp3CatalogsOpenDialog->FileName;
> >>
> >> Then I have a TADODataSet linked to the prevoius TADOConnection, and a
> >> TDataSource linked to the last.
> >> Then I have a TDBGrid linked to the TDataSource.
> >> Finally I have a TADOQuery linked to the same TADOConnection.
> >>
> >> I use the TADOQuery to query the database with SQL statements. Both
> > "SELECT"
> >> and "DELETE" command work fine, but when I try to use INSERT i got the
> >> following error message:
> >>
> >> "[snip] EOleException with message 'The current provider can't give
back
> >> multiple record sets from a unique execution' [snip]" (note I tried to
> >> translate the Italian Error message!)
> >>
> >> My actual code was:
> >>
> >> AnsiString SQLCommand=
> >>
> >> "INSERT INTO MP3TAG(Title,Artist,Album,Genre,Year,Comment,File) "
> >> "VALUES('My Title', 'My Artist', 'My Album', 'My Genre', '1978', 'Some
> >> comment', 'c:\test.mp3')";
> >>
> >> ADOQuery1->Close();
> >> ADOQuery1->SQL->Clear();
> >> ADOQuery1->SQL->Add(SQLCommand);
> >> ADOQuery1->Open();
> >>
> >> What did happen? Should I use another kind of database to enable the
sql
> >> INSERT command? If so, how to create another type of database?
> >> I only own MS Access 2003, where can I find other programs to create
> >> databases?
> >>
> >> Thank You very much in advance!
> >> Stefano B.
> >>
> >>
> >
> >
>
>
Technical Details
Message-ID:
<41c0b0ae@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41bf77e4@newsgroups.borland.com> <41c008d4@newsgroups.borland.com> <41c01d2c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,616038963bb3e51 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <41bf77e4@newsgroups.borland.com> <41c008d4@newsgroups.borland.com> <41c01d2c@newsgroups.borland.com> Subject: Re: MS Access databases and SQL insert Date: Thu, 16 Dec 2004 00:46:23 +0300 Lines: 118 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 217.73.240.118 Message-ID: <41c0b0ae@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1103147182 217.73.240.118 (15 Dec 2004 13:46:22 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail