vb.net - Datagridview to CrystalReport Error "Input array is longer than the number of columns in this table." -


i trying datagridview data crystal report, getting error message "input array longer number of columns in table."

any idea how fix error?

sub printtocr()     dim dt new datatable      each dr datagridviewrow in me.datagridview1.rows         dt.rows.add(dr.cells("productid").value, dr.cells("brandname").value, dr.cells("genericname").value, _                     dr.cells("expirationdate").value, dr.cells("price").value, _                     dr.cells("unit").value, dr.cells("quantityonhand").value) '<<<<< error here.     next     '     dim rptdoc crystaldecisions.crystalreports.engine.reportdocument     rptdoc = new crystalreport1     rptdoc.setdatasource(dt)     '     crystalreportviewer.crystalreportviewer1.reportsource = rptdoc     crystalreportviewer.showdialog()     crystalreportviewer.dispose() end sub 

this database transaction

public class data dim connstring new connection dim con new oledb.oledbconnection dim cmd new oledb.oledbcommand dim da new oledb.oledbdataadapter  public function list(byval sql string) dataset     con.connectionstring = connstring.connectionstring     con.open()     da = new oledb.oledbdataadapter(sql, con)     dim ds new dataset     da.fill(ds, "data")     con.close()     list = ds end function  public sub executesql(byval sql string)     con.connectionstring = connstring.connectionstring     con.open()     cmd.commandtext = sql     cmd.commandtype = commandtype.text     cmd.connection = con     cmd.executenonquery()     con.close() end sub 

end class

btw, datagridview connected via datasource

thanks

try ..

     dim dt new datatable      dt.columns.add("productid")     dt.columns.add("brandname")     dt.columns.add("genericname")     dt.columns.add("expirationdate")     dt.columns.add("price")     dt.columns.add("unit")     dt.columns.add("quantityonhand")      each dr datagridviewrow in me.datagridview1.rows()          dt.rows.add(dr.cells("productid").value, dr.cells("brandname").value, dr.cells("genericname").value, _                     dr.cells("expirationdate").value, dr.cells("price").value, _                     dr.cells("unit").value, dr.cells("quantityonhand").value)     next     '     dim rptdoc crystaldecisions.crystalreports.engine.reportdocument     rptdoc = new crystalreport1     rptdoc.setdatasource(dt)     crystalreportviewer.crystalreportviewer1.reportsource = rptdoc     crystalreportviewer.showdialog()     crystalreportviewer.dispose() 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -