Data Environment plus SQL Parameter in VB

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2007
Posts: 16
Reputation: Soleybancing is an unknown quantity at this point 
Solved Threads: 0
Soleybancing Soleybancing is offline Offline
Newbie Poster

Data Environment plus SQL Parameter in VB

 
0
  #1
Dec 11th, 2008
Hi, I wanted to issue a select query with where clause.

I used sql parameter in my sql query, but how do i pass the value to that parameter at run time.

Help!
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Data Environment plus SQL Parameter in VB

 
0
  #2
Dec 12th, 2008
Hi,

Try This :

Open a Data Project
Add a Connection Object (Configure to your database)
Add A Command Object (Say Command1) And Right-Click
Goto properties and Select Option SQL Statement and Type :
Select * From MyTable Where MyDate Between ? And ?
Click on Apply,
Parameter Tab Is Enabled, Go there..
Set these properties for both Parameters:
DataType = adDBDate
HostDataType =Date (VT_Date)
And Apply,
Save the Project
Now Design the DataReport1 on this Command Object...

In The Calling Form, Place 2 Date Pickers say DTFr and DTTo

Place Command Button And Show the Report like this :

  1. Load DataEnvironment1
  2. With DataEnvironment1
  3. If .rsCommand1.State <> 0 Then .rsCommand1.Close
  4. .Command1 Format(DTFr.Value,"dd-mm-yyyy"), Format(DTTo.Value,"dd-mm-yyyy")
  5. End With
  6. DataReport1.Show

Regards
Veena
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1415 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC