I am attempting to use the push model for a crystal report from a asp.net project.
I am having two problems. First when I attempt to use a sql command I am able to create the report
but when I attempt to push the data to it I get a login failed error. When I correct this I get the original
data that was used to format the report not the modified data that I am attempting to push to it.
Here is the code.
Sub BindReport2()
Dim oRpt As New CrystalReport1
Dim myConnection As New SqlClient.SqlConnection
myConnection.ConnectionString = "Server=WOODS1;Database=WEB_TEST;User ID=WebRep;Password=webrep;Trusted_Connection=False"
Dim MyCommand As New SqlClient.SqlCommand
MyCommand.Connection = myConnection
MyCommand.CommandText = "select fname, lname, address1, city, state " & _
"from T1, T2 " & _
"where T1.empid = T2.empid and state = 'New York' "
MyCommand.CommandType = CommandType.Text
Dim MyDA As New SqlClient.SqlDataAdapter
MyDA.SelectCommand = MyCommand
Dim myDS As New DataSet
'This is our DataSet created at Design Time
MyDA.Fill(myDS, "Command")
'You have to use the same name as that of your Dataset that you created during design time
'oRpt.Database.Tables.Item("Command").SetDataSource(myDS)
' This is the Crystal Report file created at Design Time
oRpt.SetDataSource(myDS)
' Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt
'oRpt.SetDatabaseLogon("user","password","server","database")
oRpt.SetDatabaseLogon("WebRep", "webrep", "WOODS1", "web_test")
CrystalReportViewer1.RefreshReport()
' Set the Crystal Report Viewer's property to the oRpt Report object that we created
End Sub
My Second issue is similar though involves using a dataset. I am able to push the data to the report if
my dataset only contains one table if it contains more than one I get no data returned to the report.
Here is the code.
Sub BindRep()
Dim oRpt As New CrystalReport2
Dim myConnection As New SqlClient.SqlConnection
myConnection.ConnectionString = "Server=WOODS1;Database=WEB_TEST;User ID=WebRep;Password=webrep;Trusted_Connection=False"
Dim strSQL As String = "select fname, lname, address1, city, state " & _
"from T1, T2 " & _
"where T1.empid = T2.empid and state = 'New York' "
Dim objAdapter As New SqlClient.SqlDataAdapter(strSQL, myConnection)
Dim objDataSet As New Dataset1
objAdapter.Fill(objDataSet, "T1, T2")
oRpt.SetDataSource(objDataSet)
' Set the SetDataSource property of the Report to the Dataset
CrystalReportViewer1.ReportSource = oRpt
End Sub
I have been able with the above code using a dataset that contains only one table to push the correct data
to the report. Any help on this issue whould be greatly appreciated.I dunno what database you're using, but I would have thought your problem occurs becuse of your SQL syntax/structure, where's your:
AS T1 INNER JOIN T2 ON (T1.empid = T2.empid )
???
If you don't join them on at least one field, the SQL parser can't resolve the WHERE clause.
Davesql
Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts
Friday, March 23, 2012
Monday, March 12, 2012
Pull pdf out of db
All,
I did it in ASP 1.0 with the datareader but in 2.0 the data reader appears to be gone, so how do i retrive a pdf out of the sql db and show it in a blank web page,
tia
jtr
You may need SqlDataReader:
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader(d=ide).aspx
Or try the sample code in this article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;326502
|||I had used the datereader before but I don't see it in the asp.net tool kit.|||import system.data
import system.data.sqlclient
You now should have sqldatareader.
|||thanks and do and workedFriday, March 9, 2012
Publishing Crystal Reports in Web
Hi,
I'm using CR9. Planning to publish them in the web. Used ASP to publish them
But Is it necessary to instal CR 9 in the server.
My CreateObject("CrystalRuntime.Application.9") Failed because of Invalid ProgId Error.
Have any idea pls tell me,
ThanksI don't know anything about Crystal Reports for the Web, but I think Crystal Enterprise was created for that. Try a search on that for your answer.|||It's working. Installed crystal reports and its corresponding web components.
Anyway, thanks for your response
I'm using CR9. Planning to publish them in the web. Used ASP to publish them
But Is it necessary to instal CR 9 in the server.
My CreateObject("CrystalRuntime.Application.9") Failed because of Invalid ProgId Error.
Have any idea pls tell me,
ThanksI don't know anything about Crystal Reports for the Web, but I think Crystal Enterprise was created for that. Try a search on that for your answer.|||It's working. Installed crystal reports and its corresponding web components.
Anyway, thanks for your response
Subscribe to:
Posts (Atom)