PDA

Click to See Complete Forum and Search --> : Data Enviroment problem


parkes
Aug 2nd, 2000, 08:50 AM
I've just started using the DE with SQL. Now I've managed to get the DE to display all my tables, views and SP no problem.

How do I get the information out of a table/view. It doesn't matter what I try I just cannot get any data to display via code.

Please please help

Nathan
Aug 2nd, 2000, 09:06 AM
To get the info from a table, view or stored procedure into a recordset to access through code create a command object in the dataenvironment (ie. right click on the connection) and in the general tab under database object choose the database object (table, view etc...) and under object name choose the object you want to use from the database. Then in code open the command object.

Under the Advanced tab make sure that returns a recordset is checked.

(DataEnvironment1.Command1) and you can then access the recordset opened (DataEnvironment1.rsCommand1).

parkes
Aug 2nd, 2000, 09:09 AM
Sorry if I seem a little thick at the minute, but could you give me a little example of the code to open the table. I've checked the DE and the advanced tab and no problem, but when I try to open anything I get no luck

Nathan
Aug 2nd, 2000, 10:35 AM
Once your command is created and set up to return a recordset it should work like this in your code:

DataEnvironment1.Command1

then you can access the recordset like this

DataEnvironment1.rsCommand1

if this doesn't make sense or work try sending me some of your code and I can take a look at it...

parkes
Aug 2nd, 2000, 10:46 AM
That worked fine thanks.
Another quetion how can I open the same table in the form of an SQL statement so that it only returns certain values

i.e

strSQL = "SELECT * FROM table WHERE ID ='" & strID & "'"

Nathan
Aug 2nd, 2000, 10:50 AM
If you want to do that here's my recommendation.

Don't open a table... :)

instead when you set up your command object in the data environment insert an sql statement like:
SELECT * FROM table WHERE ID = ?
into the SQL Statement box... the ? will set up a parameter that can be accessed from then on when you open the command us this method...

DataEnvironment1.Command1 strID

where strID is the value you want to pass to the sql string in the command... try it and let me know if it works... anymore questions feel free to ask!