Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to access first record!

Status
Not open for further replies.

falconsight

Programmer
Apr 18, 2007
24
0
0
SV
I'm using VB6 and the Crystal Reports controls that come with Visual Studio 6. My system runs WinXP SP2. My database is SQLServer 2005
I'm generating a report based on a view that already exists on the server.
The query string that works goes like this:

Code:
dim rsrepo as new ADODB.recordsource
dim sqlx as string
dim reporte as new programacion


sqlx = "select * from vprogramarev where fecha between convert(datetime,'" + Format(dtpFechaDesde.Value, "yyyymmdd") + "')  and convert(datetime,'" + Format(dtpFechaHasta.Value, "yyyymmdd") + "')"

rsRepo.Open Sqlx, ConActiva, adOpenDynamic, adLockReadOnly

reporte.DiscardSavedData
reporte.Database.SetDataSource rsRepo
CRViewer1.ReportSource = reporte
CRViewer1.ViewReport


It goes on a crosstab report, that access data thru a .ttx

When I try to use the expression
Code:
select * from vprogramarev where fecharev between convert(datetime,'" + Format(dtpFechaDesde.Value, "yyyymmdd") + "')  and convert(datetime,'" + Format(dtpFechaHasta.Value, "yyyymmdd") + "')"


on the same report the program doesn't crash, but it sends a message "Unable to access first record" an then "SQL Server error"

If you try both expressions on SQL Server, they both work, and the data are shown, so I assume is not an error on the database. Same with the expression created by VB. They prove thru.
Also, if I issue the command for a date range that has not data, the report works, showing a blank report with all the headers and footers.

I've tried to select the data with/without "order by" and specifically naming each field in SqlX, to no result.

Please some ideas!
 
Thanks for the aid...
I've already found the problem in a recordset command
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top