473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

datareport - help needed !

Hi everyone,
I am currently trying to write a report based on a View of SQL Server.
Basically, I have 3 tables : Hardware, SoftwareInstalled and Software
with SoftwareInstalled that keeps track of all the software installed
on each piece of hardware by referencing the primary keys of each
table.
So now, I have a request that retrieve information from those 3 tables
giving a list of all the hardware with their details + the software
installed.
ex:
hardware name IPAddress Software name
---------------------------------------------
PC1 192.168.0.1 Winamp
PC1 192.168.0.1 Nero
PC2 192.168.0.2 Winamp

I can link this View in VB with a DataEnvironment object and then I
display the result with a DataReport. Ok. The problem is that PC1 is
displayed twice and this is a waste of place. I want PC1 being
displayed only once with the list of software like this :
Hardware Name : PC1
IPAddress : 192.168.0.1
Software : Winamp, Nero

I am really desesperate to get that working...
If someone knows how to do this, please let me know !
Thanx.
Sam
Jul 17 '05 #1
2 4686
Hi Sam,

Alrighty....You can probably do this using a GROUP BY clause in your SQL
squery to get those records and also add a DISTINCT to your select query as
follows:

SELECT DISTINCT * FROM <TableName> GROUP BY HarwareName

or by IP Address
SELECT DISTINCT * FROM <TableName> GROUP BY IPAddress

This will eliminate unnecessary duplicates from your result: However since
you one record per application installed it will still show you two rows.
Only thing I can think of is to use something else to do the reporting and
concatenate the SoftwareNames into a comma seperated string like your
desired result show. Maybe programmatically in a vb sub. or using a cursor
object in SQL Server to select everything then loop through the records
(which is the purpose of a cursor object) and say that a variable is :
@ConcatenatedApps = @ConcatenatedApps + SoftwareName

If you really need this done from the database side and not the Application
side of things, you could create a stored procedure to concatenate the
applications and call it from a main stored procedure that woudl create the
query into a temp table
then the stored procedure could loop each object contitionned on the IP
Address for example and when that changes create a noew row of result
data....

It's doable...but be warned that depending on the amount of data you're
dealing with, performances might be dramatically affected using this method.

In VB, once you have the resultset as shown in your example then you could
loop through them and concatenate them yourself...(Say your recordset object
is called AppsSet):

Dim IPAddress As String
Dim PCName As String
Dim Installed As String

Do while not AppSet.EOF
PC Name = AppSet.Fields('HardwareName')
IPAddress = AppSet.Fields('IPAddress')
Do While IPAddress = AppSet.Fields('IPAddress')
Installed = Installed & AppSet.Fields('SoftwareName') & ", "
AppSet.MoveNext
Loop
' When you exit this last loop, you have all the info for one PC
' Get rid of the last comma added with:
Installed = Left(Installed, Len(Installed) - 1)
' the Information is now ready to print or add to a temporary recordset
' for eventual showing or printing.
' Then you loop up and start over with the next PC (IP address)
Loop

Hope this helps

Stéphane Richard
Senior Software and Technology Supervisor
http://www.totalweb-inc.com
For all your hosting and related needs

"berthelot samuel" <sa**************@voila.fr> wrote in message
news:ca**************************@posting.google.c om...
Hi everyone,
I am currently trying to write a report based on a View of SQL Server.
Basically, I have 3 tables : Hardware, SoftwareInstalled and Software
with SoftwareInstalled that keeps track of all the software installed
on each piece of hardware by referencing the primary keys of each
table.
So now, I have a request that retrieve information from those 3 tables
giving a list of all the hardware with their details + the software
installed.
ex:
hardware name IPAddress Software name
---------------------------------------------
PC1 192.168.0.1 Winamp
PC1 192.168.0.1 Nero
PC2 192.168.0.2 Winamp

I can link this View in VB with a DataEnvironment object and then I
display the result with a DataReport. Ok. The problem is that PC1 is
displayed twice and this is a waste of place. I want PC1 being
displayed only once with the list of software like this :
Hardware Name : PC1
IPAddress : 192.168.0.1
Software : Winamp, Nero

I am really desesperate to get that working...
If someone knows how to do this, please let me know !
Thanx.
Sam

Jul 17 '05 #2
I believe it's called exec:
EXEC ProcedureName(parameters)
or maybe just call it by its name:
ProcedureName(parameters)

but yes you can call procedures within procedures within procedures etc..:-)
I know I've done it many times.

like I said cursors should do the trick and give you teh results, it just
might not be the quickest way possible....but I'm not saying cursors are
terribly slow either....so far when I've had to use cursors the speed was
"adequate" to say the least :-).

let me know if you have any more questions :-). I'll be happy to help
--
Stéphane Richard
Senior Software and Technology Supervisor
http://www.totalweb-inc.com
For all your hosting and related needs
"berthelot samuel" <sa**************@voila.fr> wrote in message
news:ca**************************@posting.google.c om...
Thanx a lot Stephane for your help.
The point is that I cannot do it on the vb side cuz the datareport's
fields must be linked to the field of either a table or a view or to
the results of a stored procedure. They cannot be linked dynamically
to a recordset. This is a crap feature of th DataReport...
Besides, I did not really understand this part of your explanations :
you could create a stored procedure to concatenate the
applications and call it from a main stored procedure that woudl create the query into a temp table


How can I call a stored procedure from another one ? And if can do so
why do I need a temp table then ? I could simply link my DataReport's
fields to the second procedure (assuming we can call 'nested'
procedure...)

I will try the cursor thing anyway .
Thanx again.
Sam

"Stephane Richard" <st**************@verizon.net> wrote in message

news:<Mg******************@nwrdny01.gnilink.net>.. .
Hi Sam,

Alrighty....You can probably do this using a GROUP BY clause in your SQL
squery to get those records and also add a DISTINCT to your select query as follows:

SELECT DISTINCT * FROM <TableName> GROUP BY HarwareName

or by IP Address
SELECT DISTINCT * FROM <TableName> GROUP BY IPAddress

This will eliminate unnecessary duplicates from your result: However since you one record per application installed it will still show you two rows. Only thing I can think of is to use something else to do the reporting and concatenate the SoftwareNames into a comma seperated string like your
desired result show. Maybe programmatically in a vb sub. or using a cursor object in SQL Server to select everything then loop through the records
(which is the purpose of a cursor object) and say that a variable is :
@ConcatenatedApps = @ConcatenatedApps + SoftwareName

If you really need this done from the database side and not the Application side of things, you could create a stored procedure to concatenate the
applications and call it from a main stored procedure that woudl create the query into a temp table
then the stored procedure could loop each object contitionned on the IP
Address for example and when that changes create a noew row of result
data....

It's doable...but be warned that depending on the amount of data you're
dealing with, performances might be dramatically affected using this method.
In VB, once you have the resultset as shown in your example then you could loop through them and concatenate them yourself...(Say your recordset object is called AppsSet):

Dim IPAddress As String
Dim PCName As String
Dim Installed As String

Do while not AppSet.EOF
PC Name = AppSet.Fields('HardwareName')
IPAddress = AppSet.Fields('IPAddress')
Do While IPAddress = AppSet.Fields('IPAddress')
Installed = Installed & AppSet.Fields('SoftwareName') & ", "
AppSet.MoveNext
Loop
' When you exit this last loop, you have all the info for one PC
' Get rid of the last comma added with:
Installed = Left(Installed, Len(Installed) - 1)
' the Information is now ready to print or add to a temporary recordset ' for eventual showing or printing.
' Then you loop up and start over with the next PC (IP address)
Loop

Hope this helps

Stéphane Richard
Senior Software and Technology Supervisor
http://www.totalweb-inc.com
For all your hosting and related needs

"berthelot samuel" <sa**************@voila.fr> wrote in message
news:ca**************************@posting.google.c om...
Hi everyone,
I am currently trying to write a report based on a View of SQL Server.
Basically, I have 3 tables : Hardware, SoftwareInstalled and Software
with SoftwareInstalled that keeps track of all the software installed
on each piece of hardware by referencing the primary keys of each
table.
So now, I have a request that retrieve information from those 3 tables
giving a list of all the hardware with their details + the software
installed.
ex:
hardware name IPAddress Software name
---------------------------------------------
PC1 192.168.0.1 Winamp
PC1 192.168.0.1 Nero
PC2 192.168.0.2 Winamp

I can link this View in VB with a DataEnvironment object and then I
display the result with a DataReport. Ok. The problem is that PC1 is
displayed twice and this is a waste of place. I want PC1 being
displayed only once with the list of software like this :
Hardware Name : PC1
IPAddress : 192.168.0.1
Software : Winamp, Nero

I am really desesperate to get that working...
If someone knows how to do this, please let me know !
Thanx.
Sam

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Speed | last post by:
How to write informations from database in Page Header section like in Detal section of DataReport?
5
by: anoopgopal007 | last post by:
Hi, I am using vb6 and datareport. I am updating the tables whle the program running. But the datareport doesnot show the updated information. Its always shows the previous value. But...
6
by: pramodrepaka | last post by:
hi this is pramod i am facing a small problem Private Sub Command_Click() Dim a As String a = InputBox("enter empno") If rs.State = 1 Then rs.Close rs.Open "select * from microbiology...
0
by: nishjee | last post by:
Hello friends, i need visual basic 6.0 code to export a datareport to html other than the defult option coming with datareport. I need this very urgently because when i am exporting the datareport...
0
by: k4012656 | last post by:
hi everybody...I have to make a datareport in VB6 but the problem is when i have a parent/child commands there is no details even the labels are not appearing inside the report in detail...
3
by: k4012656 | last post by:
hi everybody...I have to make a datareport in VB6 but the problem is when i have a parent/child commands there is no details even the labels are not appearing inside the report in detail...
18
by: vishwaskothari | last post by:
i need to develop a dynamic datareport . here by the word dynamic i mean that the contents of the report will vary according to the users input. for eg : i am doing a search operation.and the...
9
smartchap
by: smartchap | last post by:
I have a table having 3 fields viz. SNo, FName and LName. The table has 10 records having SNo from 1 to 10. In DataReport I have 3 labels and 3 textboxes. I want to display all records from 1 to 10...
1
by: MaryKJolly | last post by:
I got this sample project from a website. But there is some syntax error in the statement which contains the CDate function. I can't detect the error? Can enybody help me? SUMMARY This article...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.