Article View: borland.public.delphi.database.dotnet
Article #601Passing Parameters using OleDb
From: Dale Williams
Date: Wed, 03 Nov 2004 16:02
Date: Wed, 03 Nov 2004 16:02
40 lines
2046 bytes
2046 bytes
Everyone:
I have a fairly simple test program to pass a parameter to an SQL
statement but doesn't work. The app. only takes the results and binds
them results to a data grid.
When I run the program I don't receive any errors. I just receive a
empty datatable.
If I use the following statement and don't setup a parameter, I receive
data from the query and everything is fine.
cmd := System.Data.OleDb.OleDbCommand.Create('SELECT * FROM INSAS_REC
WHERE Stores_Account = ' + ''''test'''', cnn);
Here is the problem code:
test := 'SHIP';
cnn :=
System.Data.OleDb.OleDbConnection.Create('provider=connxoledb;Persist
Security Info=True;prompt=no;Data
Source=c:\AlphaYF.CDD;Location=RMS;User
ID=connx;Password=*****;Mode=ReadWrite;');
cmd := System.Data.OleDb.OleDbCommand.Create('SELECT * FROM INSAS_REC
WHERE Stores_Account = ''?''', cnn);
cmd.Parameters.Add('a1', OleDbType.Char, 8).Value := test;
da := System.Data.OleDb.OleDbDataAdapter.Create(cmd);
dt := System.Data.DataTable.Create();
da.Fill(dt);
self.DataGrid1.DataSource := dt;
self.DataGrid1.DataBind();
Thanks for the help,
Dale Williams
Technical Details
Message-ID:
<418900fa$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,a04cffef418afd36,start X-Google-Attributes: gid1effe6,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 03 Nov 2004 11:02:24 -0500 From: Dale Williams <dwilliams@yf.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.delphi.database.dotnet Subject: Passing Parameters using OleDb Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.213.204.174 Message-ID: <418900fa$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099497722 24.213.204.174 (3 Nov 2004 08:02:02 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail