🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

NULL Parameters in TADOQuery

#419
From: Ruben Lopez
Date: Mon, 20 Nov 2006 16:05
39 lines
2004 bytes
Hi to all!

I need send a sqlquery using the TADOQuery. I use the next metod.

//****************************************************
   TADOQuery *q=new TADOQuery(NULL);
   q->Connection = this->ADOConnection1;//Conected OK
   q->SQL->Clear();
   q->SQL->Add("INSERT INTO Table Values(:Filed_Id,:Name1,:Value1)");
   q->Parameters->Clear();
   q->Parameters->ParseSQL(q->SQL->Text,true);
   q->Parameters->Items[0] = 1;
   q->Parameters->Items[1] = NULL; //I test q->Parameters->Items[1] = "";
   q->Parameters->Items[2] = NULL;
   try
   {
     q->ExecSQL();
   }
   catch(Exception *e)
   {
     Application->ShowException(e);
   }


Name1 it's a NVARCHAR(255) value whit IS NULL option.
Value1 it's an Integer value whit IS NULL option.

The problem is in the Patameter[Name1], when put the parameter to NULL, 
raise an Exception, if put a value like " " it's all right.

The exception It's in Spanish and I try to Traduce it:

	
Not this allowed to the implicit conversion of the data type TEXT to the 
data type NVARCHAR.Use the Function CONVERT TO EXECUTE THIS query.



How I can put this value to null;
Technical Details
Message-ID: <4561d245$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,ef2115b40e2af41,start
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 20 Nov 2006 17:05:39 +0100
From: Ruben Lopez <ruben.lopez@sica.es>
User-Agent: Thunderbird 1.5.0.8 (Windows/20061025)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: NULL Parameters in TADOQuery
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 80.59.94.142
Message-ID: <4561d245$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1164038725 80.59.94.142 (20 Nov 2006 08:05:25 -0700)
Lines: 39
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail