🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #658

Re: Using TAdoQuery to insert record in MS Access

#658
From: Tom
Date: Mon, 06 Feb 2006 20:31
62 lines
2480 bytes
It looks like  you're trying to enter text data in non text field, so 
check if you are inserting the correct data into the correct fields?

When entering data, name the fields in which you want to enter data, and 
then add corresponding values.

ADOQuery1->SQL->Add("INSERT INTO [Sheet1](firstName, middleName, 
lastName, age) VALUES('Luka','Gigi','Majnaric','25')


Regards




Elizabeth wrote:
> Hi,
> 
> Your solution worked. Now I want to insert a record in an excel sheet.
> The following code works when I am inserting a numeric record. e.g
> 
> ADOQuery1->SQL->Add("Insert into [Sheet1$] Values('1', '2')");
> 
>     ADOQuery1->ExecSQL();
>     ADOQuery1->Close();
> 
> But I want to insert text in an excel sheet.
> I am using the following code
> ADOQuery1->SQL->Add("Insert into [Sheet1$] Values('A', 'B')");
> 
>     ADOQuery1->ExecSQL();
>     ADOQuery1->Close();
> 
> 
> But I get a "datatype mismatch error".
> Has anyone any solution how to do it ?
> 
> Thanks,
> Elizabeth.
> 
> 
> 
> 
> "Tom" <tom@net.com> wrote in message
> news:43e39813$1@newsgroups.borland.com...
>> ADOQuery1->SQL->Add("INSERT INTO TableName (FieldName1,FieldName2,...)
>> VALUES ('Value1','Value2',...)");
>> ADOQuery1->Open();
>>
>>
>> Elizabeth wrote:
>>> Hi All,
>>>
>>> I want to insert a record in MS access database using TAdoQuery.
>>> Has anyone any idea how to do it ?
>>>
>>> thanks,
>>> Elizabeth.
>>>
>>>
> 
> 
Technical Details
Message-ID: <43e7b12c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <43e3653b$1@newsgroups.borland.com> <43e39813$1@newsgroups.borland.com> <43e6cff4@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,dd1624c1f8b2994c
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 06 Feb 2006 21:31:12 +0100
From: Tom <tom@net.com>
Reply-To:  tom@net.com
User-Agent: Thunderbird 1.5 (Windows/20051201)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Using TAdoQuery to insert record in MS Access
References: <43e3653b$1@newsgroups.borland.com> <43e39813$1@newsgroups.borland.com> <43e6cff4@newsgroups.borland.com>
In-Reply-To: <43e6cff4@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 213.202.109.184
Message-ID: <43e7b12c@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1139257644 213.202.109.184 (6 Feb 2006 12:27:24 -0700)
Lines: 62
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail