Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi,

I have a module, with 2 forms, it has Crystal Report and DataGridView(both visible=False),
Also, the mainform has a listview to which the user will select what type of report to process, then the second form (ReportOpt) appears, the user will then input date and click process.. and the sendc form(
ReportOpt
closes or is hidden,

After processing, depending on what type of report the user has selected from the listview, record should appear either on the crystal or in the DGV..

But, cant see the processed records, even the crystal or dgv is still invisible...

[EDIT]Text below was moved from comment - LOSMAC[/EDIT]

VB
 Call DBMain() 'Connection
ComboBox1.Text = "KRW"

'main form 
frmdata03.Show() 
frmtxn01.Hide() 
frmdata04.Hide()
ReportMain.Hide() 

Call GR01(TextBox4.Text, TextBox5.Text, ComboBox1.Text, frmdata03.DataGridView1) ' Method
Close() ' to release this (2nd) form

'DGV to be flooded with records which is in main form
frmdata03.DataGridView1.Width = 752
frmdata03.DataGridView1.Height = 619
frmdata03.DataGridView1.Visible = True
frmdata03.Button1.Visible = True


This is the code inside the method RSP_GR01 is a stored procedure

VB
Public Function GR01(ByVal findate1 As String, ByVal finddate2 As String, ByVal findbr As String, ByRef dgv As DataGridView)
'ByVal findcurr As String, ByRef dgv As DataGridView)
Dim con As New SqlConnection
Dim str As String = Configuration.ConfigurationManager.ConnectionStrings("mbmisConnectionString").ConnectionString
con.ConnectionString = str
con.Open()
Dim comm As SqlCommand = New SqlCommand("RSP_GR01", con)
comm.CommandType = CommandType.StoredProcedure
Dim objParam As SqlParameter
objParam = comm.Parameters.Add("@fromdate", SqlDbType.NVarChar, 10)
objParam.Direction = ParameterDirection.Input
objParam.Value = findate1
objParam = comm.Parameters.Add("@toDate", SqlDbType.NVarChar, 10)
objParam.Direction = ParameterDirection.Input
objParam.Value = finddate2
objParam = comm.Parameters.Add("@branch_CD", SqlDbType.NVarChar, 4)
objParam.Direction = ParameterDirection.Input
objParam.Value = findBr comm.ExecuteNonQuery()
Dim da As SqlDataAdapter = New SqlDataAdapter(comm)
Dim myds As New DataSet
da.Fill(myds)
dgv.DataSource = myds.Tables(0).DefaultView
End Function
Posted
Updated 31-Oct-11 10:29am
v2
Comments
Kschuler 18-Oct-11 10:35am    
What code are you using to pull the record? What code are you using to display the crystal report and the grid?
Alan Tuscano 18-Oct-11 21:13pm    
<pre lang="vb">
Call DBMain() 'Connection

ComboBox1.Text = "KRW"

frmdata03.Show() 'main form
frmtxn01.Hide() 'main form
frmdata04.Hide() 'main form
ReportMain.Hide() 'main form

Call GR01(TextBox4.Text, TextBox5.Text, ComboBox1.Text, frmdata03.DataGridView1) ' Method
Close() ' to release this (2nd) form

'DGV to be flooded with records which is in main form
frmdata03.DataGridView1.Width = 752
frmdata03.DataGridView1.Height = 619
frmdata03.DataGridView1.Visible = True
frmdata03.Button1.Visible = True</pre>


'this is the code inside the method
RSP_GR01 is a stored procedure

<pre lang="vb">Public Function GR01(ByVal findate1 As String, ByVal finddate2 As String, ByVal findbr As String, ByRef dgv As DataGridView)
'ByVal findcurr As String, ByRef dgv As DataGridView)

Dim con As New SqlConnection
Dim str As String = Configuration.ConfigurationManager.ConnectionStrings("mbmisConnectionString").ConnectionString
con.ConnectionString = str
con.Open()

Dim comm As SqlCommand = New SqlCommand("RSP_GR01", con)
comm.CommandType = CommandType.StoredProcedure

Dim objParam As SqlParameter
objParam = comm.Parameters.Add("@fromdate", SqlDbType.NVarChar, 10)
objParam.Direction = ParameterDirection.Input
objParam.Value = findate1


objParam = comm.Parameters.Add("@toDate", SqlDbType.NVarChar, 10)
objParam.Direction = ParameterDirection.Input
objParam.Value = finddate2

objParam = comm.Parameters.Add("@branch_CD", SqlDbType.NVarChar, 4)
objParam.Direction = ParameterDirection.Input
objParam.Value = findBr

comm.ExecuteNonQuery()

Dim da As SqlDataAdapter = New SqlDataAdapter(comm)
Dim myds As New DataSet

da.Fill(myds)
dgv.DataSource = myds.Tables(0).DefaultView

End Function</pre>
Maciej Los 31-Oct-11 16:30pm    
Always use improve question, OK?

1 solution

No where in the code you posted do I see you setting up the crystal report's datasource to the data you pull. Is it all setup via the designer? If so, please explain to us what you did. Also, you state that the datagridview and reportviewer are set to visiblity=false. But I don't see any place where you are setting the report viewer's visibility back to True. Either that is the vital bit of code you are missing, or you didn't post the relevant code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900