473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Set query dynamically

i want to change the report's query dynamically. means i want give input as query and then as per my query report should be set. i want to do same for the report's subreport. subreport;s query also i want to pass as main report parameter and den dat query should ne set in the subreport.

can any1 show me the way ?
Feb 5 '09 #1
2 1329
OuTCasT
374 256MB
You can set string to textbox input on your form and then use the string to set the query for the report.

Dim query as string
query = txtQuery.text

Dim sqlCom as sqlcommand = new sqlCommand(txtQuery.text)

Something like that .
Feb 12 '09 #2
OuTCasT
374 256MB
Passing parameters to your report.

Expand|Select|Wrap|Line Numbers
  1. '\\ Code to send parameter through to Crystal Report //
  2.         Dim frmReport As New Form2
  3.  
  4.         'Set parameter for report
  5.         Dim oCR As New SinglePayslipTest
  6.  
  7.         'Give parameter oCR a value
  8.         oCR.DataDefinition.FormulaFields.Item("UBWONo").Text = "'" & strPayslipSingle & "'"
  9.         Dim s As String
  10.         s = oCR.DataDefinition.FormulaFields.Item("UBWONo").Text = "'" & strPayslipSingle & "'"
  11.  
  12.         'Set sqlCommand for report
  13.         Dim sqlCOm As SqlCommand = New SqlCommand("select * from earnings where employeeid = '" & s & "'", sqlCon)
  14.         Dim DA As New SqlDataAdapter(sqlCOm)
  15.         sqlCon.Open()
  16.         Dim DS As New DataSet
  17.         Dim DT As DataTable
  18.         DA.Fill(DS, "EmployeeID")
  19.         DT = DS.Tables(0)
  20.         oCR.SetDataSource(DS)
  21.  
  22.         'Set report source of Viewer to oCR
  23.         Form2.CrystalReportViewer1.ReportSource = oCR
  24.  
  25.         'Log on information for Crystal Reports
  26.         logOnInfo = oCR.Database.Tables(0).LogOnInfo
  27.         logOnInfo.ConnectionInfo.ServerName = strOldServerName
  28.         logOnInfo.ConnectionInfo.DatabaseName = strCompanyName
  29.         oCR.Database.Tables(0).ApplyLogOnInfo(logOnInfo)
  30.         sqlCon.Close()
Feb 12 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: jason | last post by:
I could sure use some conceptualization and query help with a Page Watch System I am building in Access 2000 and Asp. I need to cycle through databae and generate a compiliation query email that...
9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
1
by: ED | last post by:
I currently have an ODBC query that hits an Oracle database. I want to bring back records for a given month based on a job completion date in the Oracle database. I would like to have the user...
3
by: jpatterson | last post by:
Hi, I need to be pointed in the right direction. I'm looking for a way to dynamically change a table in a query. I have a table called students and each fiscal year the student table will get...
4
by: deko | last post by:
When using OutputTo with a query, the 'File name' window in the 'Output To' dialog gets populated with the name of the query by default. This makes the exported file self-describing if the query...
4
by: Drum2001 | last post by:
SELECT ra_report.CCENTER, FROM ra_report WHERE (((ra_report.CCENTER) Like "*" & !! & "*" Or (ra_report.CCENTER) Like "*" & !! & "*" Or (ra_report.CCENTER) Like "*" & !! & "*" Or...
0
by: greg | last post by:
I'm doing a join on a table with a cross tab query and I only want to select the last field in the crosstab query but I get a syntax error, even if I reference it with the correct dynamically...
4
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length...
8
siridyal
by: siridyal | last post by:
I have a wholesale website that i'm working on that shows hundreds of items that are updated from time to time. These items are kept in a mysql database with several tables. I want to let the...
8
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.