Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1064
  • Last Modified:

How to Bind Crystal Report 8 with VB6 (ADO) and SQL 7

Hi, I'm working with a program in VB6 with ADO, and a SQL 7 database. I need to show or print with crystal a recordset previously generated in the program, that is a mix of three tables. The report is okey, the preview shows me the result of all the records. And I know the recordset is okey too 'cause I show it in a grid. So, the problem is the linking of the recordset to the report.
I'll show the highlights of the code:
------------------------------------------------------------------------
'Connection
Private Const strCnnSQLServer="Provider=MSDATASHAPE;Data Provider=SQLOLEDB.1;Data Source=Server1;User ID=sa;PWD=trampa;Initial Catalog=Inventario"

Private cnnInventario  As New ADODB.Connection
cnnInventario.Open strCnnSQLServer
 
'Temporary recordset
Private cmdGridPcs   As New ADODB.Command
Private rsCmdGridPcs As New ADODB.Recordset

'Pc's table
cmdGridPcs.CommandType = adCmdText
cmdGridPcs.ActiveConnection = cnnInventario

'SQL query
cmdGridPcs.CommandText = "SELECT PcCode AS 'PC', (SELECT Model FROM ModelCpus WHERE  ModelCpus.Code=StockPcs.ModelCpuCode) AS 'CPU Model', (SELECT Description FROM Marks WHERE Marks.Code=StockPcs.MarkCode) AS 'Mark', (SELECT Description FROM ModelProcessors WHERE
ModelProcessors.Code=StockPcs.ProcessorCode) AS 'Processor', Memory AS 'Mem.', HardDisk AS 'HD', Net, CdDvd AS 'CD/DVD', Sound, SerialNumber AS '# Serial', StockNumber1 AS 'Stock #1', StockNumber2 AS 'Stock #2', Observations FROM StockPcs ORDER BY PcCode"

Set rsCmdGridPcs = cmdGridPcs.Execute
Set gridPcs.DataSource = rsCmdGridPcs

 
With crStockPcs
     .Connect = strCnnSQLServer
     .ReportFileName = App.Path & "\" & "StockPcs.Rpt"
     .SetTablePrivateData 0, 3, rsCmdGridPcs
     'Are offline        .DataFiles(0)=App.Path & "\" & rsCmdGridPcs.DataMember
     'Are offline        Set .DataSource=rsCmdGridPcs.DataSource
     .WindowBorderStyle = crptFixedSingle
     .WindowLeft = 0
     .WindowMaxButton = False
     .WindowMinButton = False
     .WindowState = crptMaximized
     .WindowTitle = "Pc's Stock Report"
     .WindowTop = 0
 
     .Action = 1
End With
------------------------------------------------------------------------

Thanks for you atenttion and your time. Regards.
0
pilotgabriel
Asked:
pilotgabriel
  • 5
  • 4
2 Solutions
 
pilotgabrielAuthor Commented:
Ramesh12,
the first example you gave me don't have any info about the thing I want, it is the connection exactly I'm doing it, okey ? If you should read the code I'm using, the you can figure out another idea of the problem. You see, the second example is different to the code I'm using. I downloaded I studied it, but it matter is that it uses the data environment to get the connection, but I'm using ADO without any data environment, okey ?
Maybe if you can read the highlights of the code I put below, you can find another idea to help me. I'm looking for anything I missed in the code, but I didn't find it.
Anyway, thanks for your atenttion and your time.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ramesh12Commented:
Where is the code
0
 
ramesh12Commented:
Oh I am sorry
0
 
pilotgabrielAuthor Commented:
The code is below, if you can see maybe you can tell me you is wrong with it, or what is missing, don't you ?
0
 
pilotgabrielAuthor Commented:
Please, I still need urgent the answer to the question I did.
0
 
pilotgabrielAuthor Commented:
500 points given to the trash !!! That is what that question was !!!
I needed URGENT a solution to this question. I made it a very long long time ago, and the answers I received did not match with the question. And then, a long time after that, I still remain without the answer I wanted. I had to search another sites and another people, but if I came first here was 'cause it was 'my place' ! But now I'm asking for help like I would be I poor man ! And I put 500 points to this question, so where's my answer ???!!!
ramesh12 helped me as I can, so I apreciate that so much ! So he is not guilty ! But the entire site and all the experts gives me his back and mocks of my, maintaining a question of 500 points without answering. I did this question to be answered, not just to lie in the in the fog during months. I'm very disappointed by the behavior of this site, so unless I receive the answer I need, I will no use it any longer, and very on the oposite, I will not recommend to my colleagues to come thie site, but to use others sites with better information and help.
0
 
pilotgabrielAuthor Commented:
I said sometime ago that I want to be removed from this site. Please do not send anymore e-mail to my address. If you continue to send anymore messages to my account I will consider it like SPAM. So, you can do that at once, then shutdown my account today.
Regards.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now