Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Key cannot be null. Parameter name: key

Status
Not open for further replies.

marskills

Programmer
Oct 14, 2007
7
CA
Hello,

I'm using VB 2005, mySQL 5.0 and the built in Crystal Reports wizard.

I've tried many ways to get a report to show data but I keep ending up with the error message:

Key cannot be null. Parameter name: key

I do not have any null keys nor am I using any parameters, and now I have no hair left. Could someone please point me where to look to resolve this error?
I have searched Google but not been able to find a resolution.

The report is loaded via:
Code:
Dim myReport As New ReportDocument
        Dim myData As New DataSet
        Dim conn As New MySqlConnection
        Dim cmd As New MySqlCommand
        Dim myAdapter As New MySqlDataAdapter
        Dim strReceivingNo as String = "R0700002"
        myConnString = "server=localhost; user id=xxxx; password=xxxx; database=xxx"
        strSQL = "SELECT receiving.ID, receiving.ReceivingNo, receiving.DateReceived, " _
        & "receiving.Totes, receiving.Nets, receiving.Description, receiving.Area, " _
        & "receiving.AvgTemp, receiving.WeightLBS, receiving.Driver, receiving.AuthName, " _
        & "receiving.HarvestDate, receiving.Size, receiving.FarmID, farminfo.Name, " _
        & "farminfo.Address, farminfo.City, farminfo.Prov, farminfo.Postal, farminfo.Phone1 " _
        & "FROM receiving INNER JOIN farminfo ON receiving.FarmID = farminfo.ID " _
        & "Where(receiving.receivingNo = '" & strReceivingNo & "')"
        Try
            conn.Open()
            cmd.CommandText = strSQL
            myAdapter.SelectCommand = cmd
            myAdapter.Fill(myData)

            myReport.Load(".\rptDeliverySlip.rpt")
            myReport.SetDataSource(myData)

            CrystalReportViewer1.ReportSource = myReport
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Report could not be created", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
'=========================================

The XML file to create the report:
Code:
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="Table">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="ID" type="xs:unsignedInt" minOccurs="0" />
                <xs:element name="ReceivingNo" type="xs:string" minOccurs="0" />
                <xs:element name="DateReceived" type="xs:dateTime" minOccurs="0" />
                <xs:element name="Totes" type="xs:unsignedInt" minOccurs="0" />
                <xs:element name="Nets" type="xs:unsignedInt" minOccurs="0" />
                <xs:element name="Description" type="xs:string" minOccurs="0" />
                <xs:element name="Area" type="xs:string" minOccurs="0" />
                <xs:element name="AvgTemp" type="xs:double" minOccurs="0" />
                <xs:element name="WeightLBS" type="xs:double" minOccurs="0" />
                <xs:element name="Driver" type="xs:string" minOccurs="0" />
                <xs:element name="AuthName" type="xs:string" minOccurs="0" />
                <xs:element name="HarvestDate" type="xs:dateTime" minOccurs="0" />
                <xs:element name="Size" type="xs:string" minOccurs="0" />
                <xs:element name="FarmID" type="xs:unsignedInt" minOccurs="0" />
                <xs:element name="Name" type="xs:string" minOccurs="0" />
                <xs:element name="Address" type="xs:string" minOccurs="0" />
                <xs:element name="City" type="xs:string" minOccurs="0" />
                <xs:element name="Prov" type="xs:string" minOccurs="0" />
                <xs:element name="Postal" type="xs:string" minOccurs="0" />
                <xs:element name="Phone1" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <Table>
    <ID>1</ID>
    <ReceivingNo>R0800001</ReceivingNo>
    <DateReceived>2007-10-11T11:59:00-07:00</DateReceived>
    <Totes>10</Totes>
    <Nets>10</Nets>
    <Description>Test Desc 1</Description>
    <Area>Area1</Area>
    <AvgTemp>23.5</AvgTemp>
    <WeightLBS>2000</WeightLBS>
    <Driver>Mr. Driver</Driver>
    <AuthName>1234</AuthName>
    <HarvestDate>2007-10-11T12:00:00-07:00</HarvestDate>
    <Size>Large</Size>
    <FarmID>1</FarmID>
    <Name>gindoor</Name>
    <Address>123 Main Street</Address>
    <City>Booytay</City>
    <Prov>BC</Prov>
    <Postal>V9K 1D3</Postal>
  </Table>
</NewDataSet>
Thanks,

Rory Keogh
 
just a guess

Where(receiving.receivingNo

should be

Where (receiving.receivingNo
 
Thanks for the reply but still the same error message. The SQL statement works and returns the record when used in the mySQL Query Browser and in the VB 2005 Query Browser.

Rory
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top