Link to home
Start Free TrialLog in
Avatar of KDSayers
KDSayersFlag for United States of America

asked on

VB6 Data Report Designer

OK... the question that keeps coming up.  HOW do I get the Data Report Designer to work with SQL statements?

I've read it all... In the DataEnvironment:

In Dataenvironment write a command

1)this is in General tab of dataenvironment

SELECT * from customer where custcode = ?

2) In the Paramentrs tab write dataype of ur table field(here datatype of
Custcode) And Host Data Type.

Well, I get that far and I can't even ACCESS the Parameters section under the Parameters tab.

How about this:

No dataenviroment is needed.

....
Set DataReport.DataSource = rs
Datareport.show

Place Unbound TextBoxes on your Datareport and type in the name of the field in the DataField Property.  That is it.

That hasn't worked either.  I either get a "Invalid DataSource" or "Type Mismatch (13)" error.  

So what is it that REALLY needs to be done?  What I need is to do is an SQL statement, which means going to a RecordSet.  Then once I have my RecordSet, I want to be able to use this as the source for my report.  Please tell me how and please be detailed.

Thanks.

KDSayers
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Avatar of Sage020999
Sage020999

Instead of placing the *, specify the field names.  You can also you the data connection to drag the tables you need into the data enviroment.
Avatar of KDSayers

ASKER

This does not answer the specified question.  Particularly that I have paid some serious points out looking at previously asked questions related to this topic that the help did not work, and was also vague.  So I am looking for detail and the person with the best help will get the points.

Thanks.

KDS
hi,
well, I did a VB project using Data Environment. It worked fine.

1. Give the command name
2. Connection name
3. SQL statement

Parameter:
name - give it a name
Direction -  input
Data_type   - adVarChar
size   -   xx
Host Data Type  -  String (VT_BSTR)
Required   - true

For Integer:
Data Type  - adInteger
no size, scale, precision  (all 0)
Host Data_Type - integer(VT_I2)
Required  - True

it should work.
Inside Advanced Tab,
Cursor location is 3.


Good Luck
Bill
You can use the DataEnvironment (DE):

make a command using your sql-statement, or make a stored procedure in sql server and point to it.

Then set the DataSource property of the DataReport (DR) to the DE and the DataMember to the command (let's say cmdMine).

Before invoking the DR close the DE connection:

If DE.Connection1.State = adStateOpen Then DE.Connection1.Close

Then re-open it and invoke the command including the parameter (parm1)

DE.connection1.Open
DE.cmdMine parm1

Then invoke the report:

DE.Show vbModal
Unload DE 'don't forget to unload it else it will remain in memory!!

After this close you can close the connection again to prevent memory loss:

DE.Connection1.Close

Good luck!

D'Mzzl!
RoverM
ASKER CERTIFIED SOLUTION
Avatar of garrenb
garrenb
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Comment accepted as answer
This was the detail needed to get the job done.  Thanks for your help.