Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
Crystal Reports e reportistica
Errore Function
giovedì 29 novembre 2007 - 11.56
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
ape81
Profilo
| Newbie
27
messaggi | Data Invio:
gio 29 nov 2007 - 11:56
ciao,
sto lavorando in VB.net, VisualStudio 200,Crystal Report, MySQL2005
Ho creato una Form dove e' possibile visualizzare piu' report.
Per compattare il codice ho creato questa funzione:
Function CReport(ByVal id As String)
Dim oCrystalReport As New ReportClass
oCrystalReport.FileName = id
oCrystalReport.Load()
oCrystalReport.SetDatabaseLogon("......", "*******")
oCrystalReport.VerifyDatabase()
'--- Set Crystal Viewer to point at oCrystalReport ---
CRselect.Visible = True
CRselect.ReportSource = oCrystalReport
CRselect.ShowFirstPage()
End Function
a questa funzione passo il valore dei file .rpt (id) che voglio visualizzare.
funziona tutto ma sull' End Function mi si genera un errore che per ora non mi crea problemi ma vorrei capire di che si tratta. l'errore e' il seguente:
"Function “CReport” doesn’t return a value on all code paths. A null reference exception could occur at run time when the result is used."
grazie.
elisa
sanbiz
Profilo
| Senior Member
208
messaggi | Data Invio:
gio 29 nov 2007 - 12:09
>ciao,
>sto lavorando in VB.net, VisualStudio 200,Crystal Report, MySQL2005
>
>Ho creato una Form dove e' possibile visualizzare piu' report.
>Per compattare il codice ho creato questa funzione:
>
>Function CReport(ByVal id As String)
>
> Dim oCrystalReport As New ReportClass
>
> oCrystalReport.FileName = id
> oCrystalReport.Load()
> oCrystalReport.SetDatabaseLogon("......", "*******")
> oCrystalReport.VerifyDatabase()
>'--- Set Crystal Viewer to point at oCrystalReport ---
> CRselect.Visible = True
> CRselect.ReportSource = oCrystalReport
> CRselect.ShowFirstPage()
>
>End Function
>
>a questa funzione passo il valore dei file .rpt (id) che voglio
>visualizzare.
>funziona tutto ma sull' End Function mi si genera un errore che
>per ora non mi crea problemi ma vorrei capire di che si tratta.
>l'errore e' il seguente:
>
>"Function “CReport” doesn’t return a value on all code paths.
>A null reference exception could occur at run time when the result
>is used."
>
L'errore è dovuto al fatto che una Function si aspetta di restituire un valore ed infatti dovresti specificare una cosa del genere
Private Function CReport(ByVal id As String) as String/Integer/ecc.
..
...
....
Return mioValoreDiRitorno
End Function
Nel tuo esempio sarebbe più corretto definire una Sub
Private Sub CReport(ByVal id As String)
..
...
....
End Sub
--
Sandro Bizioli
http://blogs.dotnethell.it/sandro/
totti240282
Profilo
| Guru
1.574
messaggi | Data Invio:
gio 29 nov 2007 - 12:10
Perchè usi una funzione a cui non trasferisci nessun risultato,e lui te lo segnala,non è proprio un errore,diciamo segnalazione.
C'è solo un capitano !!!!!!
ape81
Profilo
| Newbie
27
messaggi | Data Invio:
gio 29 nov 2007 - 13:26
Ok.
Grazie mille.
Devo usare...
Private sub()
.....
end sub
ciao
elisa
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !