Data Environment Command

bobok
bobok used Ask the Experts™
on
Can a SQL statement in a Command object of DataEnvironment be dynamically modified at runtime in vb6? If so what is the syntax?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Yes it can be midified by using the CommandText property. Just assign the new SQL statement to the CommandText property.

Author

Commented:
I have modified CommandText but how do I effect it. Give me the syntax.

Commented:
Lets say you have created a Command object by the name objCommand. Then this is the way you will change its CommandText.

DataEnvironment1.Commands("objCommand").CommandText = "Select * from tblPersonMaster"
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I followed your example

DataEnvironment1.Commands("Cmd3").CommandText = "Select * from ch_acct_ledg where cod_acct_no = " & Text1.Text

and I am now getting

"invalid procedure call or argument" when I run it.

Commented:
Check two things:
1. Whether Cmd3 is present there.
2. if cod_acct_no is an Integer field, then use cint(Text1.Text) instead of Text1.Text.

Author

Commented:
It is of char type and I converted it. But now I am getting

Failed getting Rowset(s)from current data source.
Commented:
bobok there is some problem other than Command Text property. Check your SQL Statement and the table fields.

Author

Commented:
I checked the table and the SQL statement. It is now working.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial