
VB6 - CR7 - SQL Server - Want to send either SQL or ADO recordset to report
Hello there Mike... I am currently using CR 8.5 and I don't know if this
will help, but this is what I do,
Public Sub subRepInt(ByRef crxRep As CRAXDDRT.Report, ByRef cnnDB As
ADODB.Connection, ByVal strQuery As String)
Dim intCount As Integer
crxRep.Database.SetDataSource gstrSDN 'gstrSDN is a global
variable that has the DSN Name
For intCount = 1 To crxRep.Database.Tables.Count
crxRep.Database.Tables(intCount).SetLogOnInfo gstrSDN, gstrDBName,
gstrDBUser, gstrDBPass 'Same for gstrSDN, gstrDBName is the DB
name,
'gstrUser is the DBServer User and ths gstrPass is
'the DBServer Password
crxRep.Database.Tables(intCount).Location =
crxRep.Database.Tables(intCount).Name
Next intCount
crxRep.SQLQueryString = strQuery
End Sub
Hope this helps....
--
Saludos.
Edgar Contreras
(Gua de netiquette del foro)
http://perso.wanadoo.es/rubenvigon/foro
"La informacion es presentada como es y sin garantia alguna"
Quote:
> A dumptruck full of good karma to the person who helps me solve this
> one...
> I'm using the CR7 OCX in a VB6 project (no, I'd rather not switch to
> the RDC at this point).
> I have created a report based on a TTX and at runtime I want to
> either:
> 1) Send a pre-built SQL statement to the report, along with .Connect
> information for a user-specified SQL Server database
> or
> 2) Send an ADO Recordset directly to the report
> Obviously, the SQL statement (or the Recordset) will have columns
> exactly matching the TTX file.
> No matter what I have tried so far, I always get error 20599, "Cannot
> open SQL server".
> Note that basing the report on a TTX is NOT a requirement. The only
> requirement is that I am able to build a query at runtime and send
> either that query's SQL or an ADO recordset to a Crystal report, using
> the OCX.
> The ONLY way I've been able to come even close is to build the report
> directly against SQL Server, then change the DSN information at
> runtime. Problem is, the queries I want to use to run the reports are
> far more complex than I want to try to emulate using CR7's
> data-joiner. It'll be much much easier for me if the VB program can
> just generate the SQL and then send it off, or run it and provide an
> ADO recordset.
> Thanks in advance,
> -Mike