SQL string of command object in DataEnvironment

SQL string of command object in DataEnvironment

Post by Rui Alve » Thu, 31 May 2001 15:46:21



Hi

I'm creating a Data Project with Visual Basic 6.
I'm designing a database with DataEnvironment Activex Designer.

I want to have the possibility of changing the SQL statement of the command
object at runtime.
I already saw the SQL string in the CommandText propertie of the command
object, but if I write:

DataEnvironment1.rsCommand1.CommandText = " SELECT * FROM Table1 WHERE
Table1.Customer = CustomerVariable"

Visual Basic does not accept CommandText.

So, what should I put after rsCommand1?:

DataEnvironment1.rsCommand1.... = " SELECT * FROM Table1 WHERE
Table1.Custommer = CustomerVariable"

(The Database was created in Microsoft Access).

Thanks a lot for your attention.
Best Regards.
Rui

 
 
 

SQL string of command object in DataEnvironment

Post by Michel » Thu, 31 May 2001 20:52:56


I'm not sure if I correcly understand what you want to do but if
"CustomerVariable" is a parameter you want to enter then you must first call
the command with the parameter:

  'Open the command
  DataEnvironment1.Command1 CustId

  'rsCommand1 is now ready to use
  Do Until rsCommand1.EOF
    ...
  Loop

where CustId is a local variable.

HTH


Quote:> Hi

> I'm creating a Data Project with Visual Basic 6.
> I'm designing a database with DataEnvironment Activex Designer.

> I want to have the possibility of changing the SQL statement of the
command
> object at runtime.
> I already saw the SQL string in the CommandText propertie of the command
> object, but if I write:

> DataEnvironment1.rsCommand1.CommandText = " SELECT * FROM Table1 WHERE
> Table1.Customer = CustomerVariable"

> Visual Basic does not accept CommandText.

> So, what should I put after rsCommand1?:

> DataEnvironment1.rsCommand1.... = " SELECT * FROM Table1 WHERE
> Table1.Custommer = CustomerVariable"

> (The Database was created in Microsoft Access).

> Thanks a lot for your attention.
> Best Regards.
> Rui


 
 
 

SQL string of command object in DataEnvironment

Post by res0a1j » Thu, 31 May 2001 23:13:12


You need to change the CommandText of the de command to read:
"Select.....Where table1.customer = ?"

Then use this code:

With DataEnvironment1
    If .rsCommand1.State = adStateOpen Then
        .rsCommand1.Close
    End If
    .Command1 (your variable here)
End With

HTH


Quote:> Hi

> I'm creating a Data Project with Visual Basic 6.
> I'm designing a database with DataEnvironment Activex Designer.

> I want to have the possibility of changing the SQL statement of the
command
> object at runtime.
> I already saw the SQL string in the CommandText propertie of the command
> object, but if I write:

> DataEnvironment1.rsCommand1.CommandText = " SELECT * FROM Table1 WHERE
> Table1.Customer = CustomerVariable"

> Visual Basic does not accept CommandText.

> So, what should I put after rsCommand1?:

> DataEnvironment1.rsCommand1.... = " SELECT * FROM Table1 WHERE
> Table1.Custommer = CustomerVariable"

> (The Database was created in Microsoft Access).

> Thanks a lot for your attention.
> Best Regards.
> Rui