error "system.argumentException; Column ' test_id2' does not belong to table Table.
I am getting the error "system.argumentException; Column ' test_id2' does not belong to table Table. At System.Data.GetDataColumn( string columnname0
at system.data.datarow.get_item(string columnName).
This error is occuring right after I set the parametervalues in the report object of the Crystal report.(Note this a visual basic.net 2005 windows form application.)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
Dim sql As String
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Dim i As Integer
Dim test_id1 As Integer
Dim test_id2 As Integer
'located crystal report from
Dim strReportPath As String = "C:\tstReport.rpt"
connetionString = "Data Source=sourcename;Initial Catalog=databasename;User ID=uname;Password=pwd"
connection = New SqlConnection(connetionString)
sql = "select * from tstTable"
Try
'For i = 0 To ds.Tables(0).Rows.Count - 1
cryRpt.load(strReportPath)
test_id1 = ds.Tables(0).Rows(i).Item("test_id1")
test_id2 = ds.Tables(0).Rows(i).Item("test_id2")
cryRpt.SetParameterValue("@Parm_id1", test_id1)
cryRpt.SetParameterValue("@Parm2_id", test_id2)
cryRpt.SetDatabaseLogon("uname", "pwd")
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
The value for the first parameter @Parm_1d1 value to the crystal report version 11 is correct. However, when trying to access the second @Parm_1d2 parameter ,the values past to the crystal report is not correct.
Can you tell me what is causing the problem?
Thanks!
I am getting the error "system.argumentException; Column ' test_id2' does not belong to table Table. At System.Data.GetDataColumn( string columnname0
at system.data.datarow.get_item(string columnName).
This error is occuring right after I set the parametervalues in the report object of the Crystal report.(Note this a visual basic.net 2005 windows form application.)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
Dim sql As String
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Dim i As Integer
Dim test_id1 As Integer
Dim test_id2 As Integer
'located crystal report from
Dim strReportPath As String = "C:\tstReport.rpt"
connetionString = "Data Source=sourcename;Initial Catalog=databasename;User ID=uname;Password=pwd"
connection = New SqlConnection(connetionString)
sql = "select * from tstTable"
Try
'For i = 0 To ds.Tables(0).Rows.Count - 1
cryRpt.load(strReportPath)
test_id1 = ds.Tables(0).Rows(i).Item("test_id1")
test_id2 = ds.Tables(0).Rows(i).Item("test_id2")
cryRpt.SetParameterValue("@Parm_id1", test_id1)
cryRpt.SetParameterValue("@Parm2_id", test_id2)
cryRpt.SetDatabaseLogon("uname", "pwd")
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
The value for the first parameter @Parm_1d1 value to the crystal report version 11 is correct. However, when trying to access the second @Parm_1d2 parameter ,the values past to the crystal report is not correct.
Can you tell me what is causing the problem?
Thanks!