We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

pilotgabriel
pilotgabriel asked
on
Medium Priority
1,097 Views
Last Modified: 2012-06-21
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.
Comment
Watch Question

Author

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.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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 ?

Author

Commented:
Please, I still need urgent the answer to the question I did.

Author

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.

Author

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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.