-
Problem regarding Crystal Report 9.0 and VB6.0 Environment
• Variable Declaration
Dim Cn As ADODB.Connection
Dim Conn As String
Dim crystlApp As New CRAXDRT.Application
Dim crystlRpt As CRAXDDRT.Report
• “CRViewer91” control inserted on VB form.
• Write VB code for connection to Oracle 8 in Form Load
Private Sub Form_Load()
Conn = "UID=abcde; PWD=youme; DRIVER={Microsoft ODBC for Oracle}; SERVER=;"
Set Cn = New ADODB.Connection
With Cn
.ConnectionString = Conn
.CursorLocation = adUseClient
.Open
End With
End Sub
• VB code to access Crystal Report 9.0 (file.rpt)
1. Dim QsqlStock As String
2. Dim CmdStock As ADODB.Command
3. Dim RsStock As ADODB.Recordset
4. QsqlStock = "select * from product"
5. Set CmdStock = New ADODB.Command
6. With CmdStock
.ActiveConnection = Cn
.CommandText = QsqlStock
.CommandType = adCmdText
End With
7. Set RsStock = New ADODB.Recordset
8. Set RsStock = CmdStock.Execute
9. Set crystlRpt = crystlApp.OpenReport("D:\St\rp1.rpt", 1)
10. crystlRpt.Database.SetDataSource RsStock
11. crystlRpt.DiscardSavedData
12. CRViewer91.ReportSource = crystlRpt
13. CRViewer91.ViewReport
14. CRViewer91.Zoom 80
The working of above code is too good for single table only, check at line No.4.
Problem is that when I used two or more related tables (in sense of primary key) at line No.4 i.e.
4. QsqlStock = "select * from product, pricelist"
Or
4. QsqlStock = "select product.pid, product.pname, pricelist.ipr from
product, pricelist"
Then my code generate following error:-
Logon failed.
Details: ADO Error Code: 0x80040e4d
Source: Microsoft OLE DB Provider for Oracle
Description: ORA-01017: invalid username/password; logon denied
Native Error: 1017”
Anyone may kindly help to resolve this problem
Advance thanks for such act.
-
What information are you trying to gather in your recordset from the two tables?
I think your SELECT query needs to be tweaked a bit.
-
I am trying to gather the following information in recordset
- PNAME from "product" table
- IPR, WSR, RSR from "pricelist" table
Structure of both tables are as follow:-
Table 1: product
Name Null? Type
------------------------------- -------- ----
PID NOT NULL VARCHAR2(3)
PNAME VARCHAR2(20)
QTYOPENSTOCK NUMBER(6)
QTYEXE NUMBER(6)
PACKING NUMBER(6)
DAMAGEQTY NUMBER(6)
Table 2: pricelist
Name Null? Type
------------------------------- -------- ----
PID NOT NULL VARCHAR2(3)
IPR NUMBER(6,3)
WSR NUMBER(6,3)
RSR NUMBER(6,3)
Similar Threads
-
By ubest4me in forum VB Classic
Replies: 1
Last Post: 12-29-2008, 09:36 AM
-
By ReportMan in forum VB Classic
Replies: 2
Last Post: 05-29-2007, 05:43 AM
-
By query4u in forum VB Classic
Replies: 1
Last Post: 06-08-2006, 09:16 AM
-
By ReportMan in forum VB Classic
Replies: 0
Last Post: 07-26-2005, 03:09 AM
-
By susan in forum VB Classic
Replies: 3
Last Post: 01-08-2003, 03:00 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|