2012-04-17 51 views
0

有一个搜索按钮,以查看datagridview使用year..so时的报表,当数据库中有更多的项目在那里对应它一年(说2012年)..上面的例外是通过填充datgridview引发的,当它试图连接水晶报表时发生问题,它显示错误...请记住,只有在我的数据库中有更多记录时,我才会面对此问题(正好超过100行)......当我从数据库中删除几行,它的工作原理fine..I已经创建了一个表,并补充说,表中的数据集,然后分配了表1作为数据源的Crystal报表错误:从字符串加载报告转换失败,键入整数无效

Public Class crystalform1 

Dim r As DataRow 
Dim t As DataTable 
Dim ds1 As New DataSet1() 
Sub New() 

    ' This call is required by the designer. 
    InitializeComponent() 

    ' Add any initialization after the InitializeComponent() call. 



    t = ds1.Tables.Add("DataTable1") 


    t.Columns.Add("invoiceno", Type.GetType("System.Int32")) 
    t.Columns.Add("customer_name", Type.GetType("System.String")) 
    t.Columns.Add("customer_phonenumber", Type.GetType("System.Int32")) 
    t.Columns.Add("date", Type.GetType("System.String")) 
    t.Columns.Add("product_item", Type.GetType("System.String")) 
    t.Columns.Add("bookno", Type.GetType("System.Int32")) 
    t.Columns.Add("serialno", Type.GetType("System.Int32")) 
    t.Columns.Add("price", Type.GetType("System.Single")) 
    t.Columns.Add("quantity", Type.GetType("System.Int32")) 

    t.Columns.Add("discount", Type.GetType("System.Int32")) 

    t.Columns.Add("paymentby", Type.GetType("System.String")) 
    t.Columns.Add("checkno", Type.GetType("System.Int32")) 
    t.Columns.Add("checkdate", Type.GetType(" System.String")) 
    t.Columns.Add("total", Type.GetType("System.Single")) 
    t.Columns.Add("totalamount", Type.GetType("System.Single")) 
End Sub 
Sub formcall(ByVal invoiceno As Integer, ByVal date1 As Date, ByVal customername As String, ByVal customerphone As Integer, ByVal product As String, ByVal bookno As Integer, ByVal serialno As Integer, ByVal price As Single, ByVal quantity As Integer, ByVal discount As Integer, ByVal payment As String, ByVal checkno As Integer, ByVal checkdate As String, ByVal total As Single, ByVal totalamount As Single) 
    ' This call is required by the designer. 
    If IsDate(checkdate) Then 
     CType(checkdate, Date).ToShortDateString() 
    End If 


    r = t.NewRow() 
    r("invoiceno") = invoiceno 
    r("customer_Name") = customername 
    r("customer_Phonenumber") = customerphone 
    r("date") = date1.ToShortDateString 
    r("product_item") = product 
    r("bookNo") = bookno 
    r("serialNo") = serialno 
    r("price") = price 
    r("quantity") = quantity 
    r("discount") = discount 
    r("paymentby") = payment 
    r("checkno") = checkno 
    r("checkdate") = checkdate 
    r("total") = total 
    r("totalamount") = totalamount 

    t.Rows.Add(r) 
    Dim objRpt As New CrystalReport2 


Try 
      objRpt.SetDataSource(ds1.Tables(1)) 
      CrystalReportViewer1.ReportSource = objRpt /*exception is showing here*/ 
     Catch ex As Exception 
      MsgBox("Report Error", ex.Message()) 
     End Try 



End Sub 
+0

哪里是代码? – 2012-04-17 12:34:10

回答

1

我自己解决了这个问题,问题是,如果数据库中有更多的数据,我的水晶报表会多次加载,因为我已经在formcall()方法里设置了水晶报表的数据源,这个方法当每行添加到表中时调用的次数超过100次,因此同一个报告将多次加载。我在新方法中声明了“setDatasource(ds.table(1))”,该方法仅在添加后才由click_button事件调用所有行到数据源表..感谢您的所有帮助

1

试评所有这些行

r("invoiceno") = invoiceno 
r("customer_Name") = customername 
r("customer_Phonenumber") = customerphone 
r("date") = date1.ToShortDateString 
r("product_item") = product 
r("bookNo") = bookno 
r("serialNo") = serialno 
r("price") = price 
r("quantity") = quantity 
r("discount") = discount 
r("paymentby") = payment 
r("checkno") = checkno 
r("checkdate") = checkdate 
r("total") = total 
r("totalamount") = totalamount 

然后取消一个一个注释。

+0

我甚至没有注释上面的所有内容,它仍然显示相同的错误,即使它是空白的(即t = ds1.Tables.Add(“DataTable1”) r = t.NewRow()t.Rows.Add(r ) Dim objRpt As New CrystalReport2)所有r(“xx ..”)和t.Columns.Add(“invoiceno”,Type.GetType(“xxx”))取消注释 – suhail 2012-04-18 14:56:51

+0

向数据表添加新行时发​​生问题超过100次(超过100行) – suhail 2012-04-18 15:00:25

相关问题