Home All Groups Group Topic Archive Search About

Crystal Reports in VB.NET

Author
5 Sep 2006 11:17 PM
Stephen Plotnick
I am able to create a Crystal report and get it to go to the screen., print,
Excel, etc.

What I want to do now is allow for my VB.NET (2003) program to dynamically
build a "WHERE clause"

For example;

I have 4000 records in an Access DB and I'm displaying Name, Address, State,
ZIP. At this time all 4000 records are being displayed. I want to the user
to print all customers in "IL". How can I build this request in the VB.NET
program and than call the form where the Crystal report is located and
display only records for "IL".

Thanks in advance,
Steve

Author
6 Sep 2006 8:45 AM
Alex
Hi Stephan

There are 2 ways of doing this, You can create a datatable or dataset
with your where clause and pass it to your report like this:

//dbmodtimeSheet, is a database class you would use ExecuteScaler etc
like you would normally do to get the datatable.

dim dt as new datatable
dim report as As New TimeSheetReporta
dt = dbmodtimeSheet.GetDataTable("SELECT * FROM History WHERE Name =
'ARITCHIE'")
report.SetDataSource(dt)
reportviewer.RunReport(report)

Or you could, use the report filter to do it, which is the way I
prefer.

//NewTimeSheetReporta is the name of your report.
dim report as As New TimeSheetReporta
//LogonInfo is set up to prevent it asking you for the login all the
time.
LogonInfo.ConnectionInfo.UserID = user
LogonInfo.ConnectionInfo.Password = pw
  report.Database.Tables(0).ApplyLogOnInfo(LogonInfo)
report.Database.Tables(1).ApplyLogOnInfo(LogonInfo)
report.RecordSelectionFormula = "{History.Weekno} = " & NumWeekno.Text
reportviewer.RunReport(report)



Stephen Plotnick wrote:

Show quoteHide quote
> I am able to create a Crystal report and get it to go to the screen., print,
> Excel, etc.
>
> What I want to do now is allow for my VB.NET (2003) program to dynamically
> build a "WHERE clause"
>
> For example;
>
> I have 4000 records in an Access DB and I'm displaying Name, Address, State,
> ZIP. At this time all 4000 records are being displayed. I want to the user
> to print all customers in "IL". How can I build this request in the VB.NET
> program and than call the form where the Crystal report is located and
> display only records for "IL".
>
> Thanks in advance,
> Steve
Author
6 Sep 2006 1:27 PM
Stephen Plotnick
Thanks,

It seems the reportviewer is for VB 2005. Is there an equivalent for vb.net
(2003)?

Steve
Show quoteHide quote
"Alex" <aritc***@dashcomputer.co.uk> wrote in message
news:1157532311.935093.219560@h48g2000cwc.googlegroups.com...
> Hi Stephan
>
> There are 2 ways of doing this, You can create a datatable or dataset
> with your where clause and pass it to your report like this:
>
> //dbmodtimeSheet, is a database class you would use ExecuteScaler etc
> like you would normally do to get the datatable.
>
> dim dt as new datatable
> dim report as As New TimeSheetReporta
> dt = dbmodtimeSheet.GetDataTable("SELECT * FROM History WHERE Name =
> 'ARITCHIE'")
> report.SetDataSource(dt)
> reportviewer.RunReport(report)
>
> Or you could, use the report filter to do it, which is the way I
> prefer.
>
> //NewTimeSheetReporta is the name of your report.
> dim report as As New TimeSheetReporta
> //LogonInfo is set up to prevent it asking you for the login all the
> time.
> LogonInfo.ConnectionInfo.UserID = user
> LogonInfo.ConnectionInfo.Password = pw
>  report.Database.Tables(0).ApplyLogOnInfo(LogonInfo)
> report.Database.Tables(1).ApplyLogOnInfo(LogonInfo)
> report.RecordSelectionFormula = "{History.Weekno} = " & NumWeekno.Text
> reportviewer.RunReport(report)
>
>
>
> Stephen Plotnick wrote:
>
>> I am able to create a Crystal report and get it to go to the screen.,
>> print,
>> Excel, etc.
>>
>> What I want to do now is allow for my VB.NET (2003) program to
>> dynamically
>> build a "WHERE clause"
>>
>> For example;
>>
>> I have 4000 records in an Access DB and I'm displaying Name, Address,
>> State,
>> ZIP. At this time all 4000 records are being displayed. I want to the
>> user
>> to print all customers in "IL". How can I build this request in the
>> VB.NET
>> program and than call the form where the Crystal report is located and
>> display only records for "IL".
>>
>> Thanks in advance,
>> Steve
>
Author
7 Sep 2006 1:04 AM
Stephen Plotnick
reportviewer.RunReport(report)

Gives me an error. Am I mssing something that needs to added somewhere?

Show quoteHide quote
"Alex" <aritc***@dashcomputer.co.uk> wrote in message
news:1157532311.935093.219560@h48g2000cwc.googlegroups.com...
> Hi Stephan
>
> There are 2 ways of doing this, You can create a datatable or dataset
> with your where clause and pass it to your report like this:
>
> //dbmodtimeSheet, is a database class you would use ExecuteScaler etc
> like you would normally do to get the datatable.
>
> dim dt as new datatable
> dim report as As New TimeSheetReporta
> dt = dbmodtimeSheet.GetDataTable("SELECT * FROM History WHERE Name =
> 'ARITCHIE'")
> report.SetDataSource(dt)
> reportviewer.RunReport(report)
>
> Or you could, use the report filter to do it, which is the way I
> prefer.
>
> //NewTimeSheetReporta is the name of your report.
> dim report as As New TimeSheetReporta
> //LogonInfo is set up to prevent it asking you for the login all the
> time.
> LogonInfo.ConnectionInfo.UserID = user
> LogonInfo.ConnectionInfo.Password = pw
>  report.Database.Tables(0).ApplyLogOnInfo(LogonInfo)
> report.Database.Tables(1).ApplyLogOnInfo(LogonInfo)
> report.RecordSelectionFormula = "{History.Weekno} = " & NumWeekno.Text
> reportviewer.RunReport(report)
>
>
>
> Stephen Plotnick wrote:
>
>> I am able to create a Crystal report and get it to go to the screen.,
>> print,
>> Excel, etc.
>>
>> What I want to do now is allow for my VB.NET (2003) program to
>> dynamically
>> build a "WHERE clause"
>>
>> For example;
>>
>> I have 4000 records in an Access DB and I'm displaying Name, Address,
>> State,
>> ZIP. At this time all 4000 records are being displayed. I want to the
>> user
>> to print all customers in "IL". How can I build this request in the
>> VB.NET
>> program and than call the form where the Crystal report is located and
>> display only records for "IL".
>>
>> Thanks in advance,
>> Steve
>
Author
7 Sep 2006 8:38 AM
Alex
Well you need to put a report viewer on a form somewere and the
"TimeSheetReporta" report object needs to be a report you have created
in your project other then that I cnat think what else you need
Stephen Plotnick wrote:
Show quoteHide quote
> reportviewer.RunReport(report)
>
> Gives me an error. Am I mssing something that needs to added somewhere?
>
> "Alex" <aritc***@dashcomputer.co.uk> wrote in message
> news:1157532311.935093.219560@h48g2000cwc.googlegroups.com...
> > Hi Stephan
> >
> > There are 2 ways of doing this, You can create a datatable or dataset
> > with your where clause and pass it to your report like this:
> >
> > //dbmodtimeSheet, is a database class you would use ExecuteScaler etc
> > like you would normally do to get the datatable.
> >
> > dim dt as new datatable
> > dim report as As New TimeSheetReporta
> > dt = dbmodtimeSheet.GetDataTable("SELECT * FROM History WHERE Name =
> > 'ARITCHIE'")
> > report.SetDataSource(dt)
> > reportviewer.RunReport(report)
> >
> > Or you could, use the report filter to do it, which is the way I
> > prefer.
> >
> > //NewTimeSheetReporta is the name of your report.
> > dim report as As New TimeSheetReporta
> > //LogonInfo is set up to prevent it asking you for the login all the
> > time.
> > LogonInfo.ConnectionInfo.UserID = user
> > LogonInfo.ConnectionInfo.Password = pw
> >  report.Database.Tables(0).ApplyLogOnInfo(LogonInfo)
> > report.Database.Tables(1).ApplyLogOnInfo(LogonInfo)
> > report.RecordSelectionFormula = "{History.Weekno} = " & NumWeekno.Text
> > reportviewer.RunReport(report)
> >
> >
> >
> > Stephen Plotnick wrote:
> >
> >> I am able to create a Crystal report and get it to go to the screen.,
> >> print,
> >> Excel, etc.
> >>
> >> What I want to do now is allow for my VB.NET (2003) program to
> >> dynamically
> >> build a "WHERE clause"
> >>
> >> For example;
> >>
> >> I have 4000 records in an Access DB and I'm displaying Name, Address,
> >> State,
> >> ZIP. At this time all 4000 records are being displayed. I want to the
> >> user
> >> to print all customers in "IL". How can I build this request in the
> >> VB.NET
> >> program and than call the form where the Crystal report is located and
> >> display only records for "IL".
> >>
> >> Thanks in advance,
> >> Steve
> >