Discussion:
IBDataSet_help
(too old to reply)
Karshi
2005-06-02 05:29:22 UTC
Permalink
Hi all,
I am using the "IBDataSet" data control for my project.
I don't undersand how to create "IBXSQLVAR" (or whatever
replaces Tparams) parameters in my SelectSQL statement:
IBDataSet->SelectSQL->Text=" SELECT employee_id, first_name,
last_name from employes WHERE employee_id=:employee_id;";

Where and how do I create ":employee_id" parameter (variable)
using "IBXSQLVAR"?
Antonio Felix
2005-06-02 08:03:46 UTC
Permalink
Post by Karshi
Hi all,
I am using the "IBDataSet" data control for my project.
I don't undersand how to create "IBXSQLVAR" (or whatever
IBDataSet->SelectSQL->Text=" SELECT employee_id, first_name,
last_name from employes WHERE employee_id=:employee_id;";
Where and how do I create ":employee_id" parameter (variable)
using "IBXSQLVAR"?
Hi,

You must use

MyDataSet->Params->ByName["empoyee_id"]->AsInteger = YourVar;

HTH
Antonio
Karshi
2005-06-03 19:11:36 UTC
Permalink
Hi,
Thanks for help.
I can't still make it work! I've tried these steps:

(1) IBDataSet1->ParamByName("employee_id")->AsInteger=3;
(2) IBDataSet1->Params->ByName("employee_id")->AsInteger=3;

Both gave me <EIBClientError with message 'Field "employee_id"
not found.>
The commands were inserted before I call the "SelectSQL" statment
i.e. IBDateSet1->SelectSQL->Text="select...."
Post by Antonio Felix
Post by Karshi
Hi all,
I am using the "IBDataSet" data control for my project.
I don't undersand how to create "IBXSQLVAR" (or whatever
IBDataSet->SelectSQL->Text=" SELECT employee_id, first_name,
last_name from employes WHERE employee_id=:employee_id;";
Where and how do I create ":employee_id" parameter (variable)
using "IBXSQLVAR"?
Hi,
You must use
MyDataSet->Params->ByName["empoyee_id"]->AsInteger = YourVar;
HTH
Antonio
Antonio Felix
2005-06-03 19:26:16 UTC
Permalink
Post by Karshi
Hi,
Thanks for help.
(1) IBDataSet1->ParamByName("employee_id")->AsInteger=3;
(2) IBDataSet1->Params->ByName("employee_id")->AsInteger=3;
Both gave me <EIBClientError with message 'Field "employee_id"
not found.>
The commands were inserted before I call the "SelectSQL" statment
i.e. IBDateSet1->SelectSQL->Text="select...."
If you're using Dialect 3 you must wrap your Field Names in
Quotes:

IBDataSet->SelectSQL->Text=" SELECT \"employee_id\", \"first_name\",
\"last_name\" from \"employes\" WHERE \"employee_id\"=:employee_id;"

and then set the parameter

IBDataSet1->Params->ByName("employee_id")->AsInteger=3;

The error message you're getting probably has to do with the
missing quotes, not with the parameters assignment.

HTH
Antonio
Karshi
2005-06-12 03:36:39 UTC
Permalink
Things with "SelectSQL" work fine now, but
am having the same issue with "InsertSQL".
I can't find the params I define.
Post by Antonio Felix
Post by Karshi
Hi,
Thanks for help.
(1) IBDataSet1->ParamByName("employee_id")->AsInteger=3;
(2) IBDataSet1->Params->ByName("employee_id")->AsInteger=3;
Both gave me <EIBClientError with message 'Field "employee_id"
not found.>
The commands were inserted before I call the "SelectSQL" statment
i.e. IBDateSet1->SelectSQL->Text="select...."
If you're using Dialect 3 you must wrap your Field Names in
IBDataSet->SelectSQL->Text=" SELECT \"employee_id\", \"first_name\",
\"last_name\" from \"employes\" WHERE \"employee_id\"=:employee_id;"
and then set the parameter
IBDataSet1->Params->ByName("employee_id")->AsInteger=3;
The error message you're getting probably has to do with the
missing quotes, not with the parameters assignment.
HTH
Antonio
Jeff Overcash (TeamB)
2005-06-13 03:29:42 UTC
Permalink
You never define nor set the parameters for the InsertSQL, ModifySQL, etc. The
params are filled from the field values at the time you post.
Post by Karshi
Things with "SelectSQL" work fine now, but
am having the same issue with "InsertSQL".
I can't find the params I define.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts, build
a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act
alone, solve equations, analyze a new problem, pitch manure, program a computer,
cook a tasty meal, fight efficiently, die gallantly. Specialization is for
insects. (RAH)
Karshi
2005-06-13 14:55:42 UTC
Permalink
Thanks for help.

I am keep getting the following error:
EDatabaseError with message 'IBDataSet: Can not modify a read-only dataset.
--------------------Code----------------------------
// Starting Transaction
if (!IBDatabase1->DefaultTransaction->InTransaction)
{
IBDatabase1->DefaultTransaction->StartTransaction();
}

// Setup the SQL statement
AnsiString SQLstmt;
SQLstmt = "insert into employees (employee_id,";
SQLstmt += "first_name,last_name) ";
SQLstmt += "values (11,'John','Jackson');";

IBDataSet1->Open();
IBDataSet1->Insert();
IBDataSet1->InsertSQL->Text=SQLstmt;
IBDataSet1->Post();
IBDatabase1->DefaultTransaction->Commit();

// Reactivate the IBDataSet
IBDataSet1->Active = true;
---------------------------------------------------------------
Is this something to do with a permission on the server site?
I have "ReadOnly" set to "false".
Post by Jeff Overcash (TeamB)
You never define nor set the parameters for the InsertSQL, ModifySQL, etc. The
params are filled from the field values at the time you post.
Post by Karshi
Things with "SelectSQL" work fine now, but
am having the same issue with "InsertSQL".
I can't find the params I define.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts, build
a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act
alone, solve equations, analyze a new problem, pitch manure, program a computer,
cook a tasty meal, fight efficiently, die gallantly. Specialization is for
insects. (RAH)
Antonio Felix
2005-06-13 20:52:57 UTC
Permalink
Post by Karshi
Thanks for help.
EDatabaseError with message 'IBDataSet: Can not modify a read-only dataset.
--------------------Code----------------------------
// Starting Transaction
if (!IBDatabase1->DefaultTransaction->InTransaction)
{
IBDatabase1->DefaultTransaction->StartTransaction();
}
// Setup the SQL statement
AnsiString SQLstmt;
SQLstmt = "insert into employees (employee_id,";
SQLstmt += "first_name,last_name) ";
SQLstmt += "values (11,'John','Jackson');";
IBDataSet1->Open();
IBDataSet1->Insert();
IBDataSet1->InsertSQL->Text=SQLstmt;
IBDataSet1->Post();
IBDatabase1->DefaultTransaction->Commit();
// Reactivate the IBDataSet
IBDataSet1->Active = true;
---------------------------------------------------------------
Is this something to do with a permission on the server site?
I have "ReadOnly" set to "false".
Hi,
I don't use TIbDataset but i guess that you must set the
InsertSQL query text before the call to Open() and Insert().
Give it a try!

HTH
Antonio
Jeff Overcash (TeamB)
2005-06-14 03:40:18 UTC
Permalink
Pretty much nothing in your code is right. The simplest way to determine how to
write the SQL is first set your SelectSQL at design time. Then right click and
bring up the dataset editor. Let the editor build your SQL for you. Now you
have a good example of how the SQL should look. In code you call Insert and
then you set the field values you want and then call post. IBX handles moving
the field values from the dataset to the parameters of the InsertSQL and send
that SQL to the server.

If you are creating SQL on the fly you need to set all the SQL statements before
opening it as the SQL statements are prepared at the time of opening the select
SQL. You can not change the SQL after the result set is opened without having
the result set close.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts, build
a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act
alone, solve equations, analyze a new problem, pitch manure, program a computer,
cook a tasty meal, fight efficiently, die gallantly. Specialization is for
insects. (RAH)
Wayne Niddery [TeamB]
2005-06-04 16:42:16 UTC
Permalink
Post by Karshi
(1) IBDataSet1->ParamByName("employee_id")->AsInteger=3;
(2) IBDataSet1->Params->ByName("employee_id")->AsInteger=3;
Both gave me <EIBClientError with message 'Field "employee_id"
not found.>
The commands were inserted before I call the "SelectSQL" statment
i.e. IBDateSet1->SelectSQL->Text="select...."
You must set the SQL text *first*, then set the parameter values.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"Some see private enterprise as a predatory target to be shot, others
as a cow to be milked, but few are those who see it as a sturdy horse
pulling the wagon." - Winston Churchill
Jeff Overcash (TeamB)
2005-06-03 01:09:32 UTC
Permalink
You don't. Just get the IBSQLVar with ParamByName.
Post by Karshi
Hi all,
I am using the "IBDataSet" data control for my project.
I don't undersand how to create "IBXSQLVAR" (or whatever
IBDataSet->SelectSQL->Text=" SELECT employee_id, first_name,
last_name from employes WHERE employee_id=:employee_id;";
Where and how do I create ":employee_id" parameter (variable)
using "IBXSQLVAR"?
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts, build
a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act
alone, solve equations, analyze a new problem, pitch manure, program a computer,
cook a tasty meal, fight efficiently, die gallantly. Specialization is for
insects. (RAH)
Loading...