By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,245 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,245 IT Pros & Developers. It's quick & easy.

Crystal Reports in VB.NET

P: n/a
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
Sep 5 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Sep 6 '06 #2

P: n/a
Thanks,

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

Steve
"Alex" <ar******@dashcomputer.co.ukwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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

Sep 6 '06 #3

P: n/a
reportviewer.RunReport(report)

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

"Alex" <ar******@dashcomputer.co.ukwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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

Sep 7 '06 #4

P: n/a
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:
reportviewer.RunReport(report)

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

"Alex" <ar******@dashcomputer.co.ukwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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
Sep 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.