我用水晶報表從數据庫的多個表中抽資料出來,在textbox中輸入參數后查詢出所要的資料卻抽不到資料(我用臨時表也不行).但是用datagrid卻能現實出資料??怎么回事啊??這個星期搞不定,老板就要干掉我了.............
Dim SQLstr As String
Dim SQLstr1 As String
Dim rptdoc As New ReportDocument
Dim fname As String = "c:\inetpub\wwwroot\JDEReports\Reports\"
Dim cnnconnection As New SqlConnection(ConfigurationSettings.AppSettings("jdeweb"))Private Sub BtnViewReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnViewReport.Click
'***************************************************************'
'
'按tbdocno 和tbdocno1中輸入的數值參數查詢'
'
'***************************************************************'
Dim reporttype As String = Request.QueryString("id")
fname = fname + Request.QueryString("id") + ".rpt"
Dim ds As New ds_report
Dim StrCmd As SqlDataAdapter
'************************************************
'
'按不同的報表名稱run不同的SQL
'
'************************************************
If reporttype = "STK002" Then
SQLstr1 = "select itrans.*,imaster.desc1,lotm.mlot2 " _
& "into temptable from imaster inner join itrans on itrans.itemno2=imaster.itemno2 " _
& "left join lotm on lotm.lot=itrans.lot and lotm.costcenter=itrans.costcenter " _
& "where ltrim(itrans.costcenter)='102' and lotm.mlot2<>'null' and itrans.lot<>'' " _
& "and itrans.doctype in ('II','IA','IT','IC','IS') AND imaster.PRPT1='FGS' " _
& "ORDER BY itrans.doctype,itrans.docno,itrans.line_no" SQLstr = "select * from temptable where docdate " _
& "between '" & FormatDateTime(Tbdocno.Text, DateFormat.ShortDate) & "' " _
& "and '" & FormatDateTime(Tbdocno1.Text, DateFormat.ShortDate) & "'" StrCmd.Fill(ds, "temptable") End If
Try
rptdoc.Load(fname)
Catch ex As LoadSaveReportException
Response.Write(ex.ToString)
End Try
rptdoc.SetDataSource(ds)
CRViewer.ReportSource = rptdoc
CRViewer.Visible = True
'btnnext.Enabled = True
End Sub
Dim SQLstr As String
Dim SQLstr1 As String
Dim rptdoc As New ReportDocument
Dim fname As String = "c:\inetpub\wwwroot\JDEReports\Reports\"
Dim cnnconnection As New SqlConnection(ConfigurationSettings.AppSettings("jdeweb"))Private Sub BtnViewReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnViewReport.Click
'***************************************************************'
'
'按tbdocno 和tbdocno1中輸入的數值參數查詢'
'
'***************************************************************'
Dim reporttype As String = Request.QueryString("id")
fname = fname + Request.QueryString("id") + ".rpt"
Dim ds As New ds_report
Dim StrCmd As SqlDataAdapter
'************************************************
'
'按不同的報表名稱run不同的SQL
'
'************************************************
If reporttype = "STK002" Then
SQLstr1 = "select itrans.*,imaster.desc1,lotm.mlot2 " _
& "into temptable from imaster inner join itrans on itrans.itemno2=imaster.itemno2 " _
& "left join lotm on lotm.lot=itrans.lot and lotm.costcenter=itrans.costcenter " _
& "where ltrim(itrans.costcenter)='102' and lotm.mlot2<>'null' and itrans.lot<>'' " _
& "and itrans.doctype in ('II','IA','IT','IC','IS') AND imaster.PRPT1='FGS' " _
& "ORDER BY itrans.doctype,itrans.docno,itrans.line_no" SQLstr = "select * from temptable where docdate " _
& "between '" & FormatDateTime(Tbdocno.Text, DateFormat.ShortDate) & "' " _
& "and '" & FormatDateTime(Tbdocno1.Text, DateFormat.ShortDate) & "'" StrCmd.Fill(ds, "temptable") End If
Try
rptdoc.Load(fname)
Catch ex As LoadSaveReportException
Response.Write(ex.ToString)
End Try
rptdoc.SetDataSource(ds)
CRViewer.ReportSource = rptdoc
CRViewer.Visible = True
'btnnext.Enabled = True
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货