I have generated some SQL code
SELECT Invoice.InvoiceID, Invoice.CustomerID, Invoice.RouteNumber,
Invoice.TreatmentType, Invoice.Information, Invoice.StreetAddress,
Invoice.Postcode,
Invoice.Invoicecost, Invoice.InvoiceDate
FROM (Invoice INNER JOIN
Customer ON Invoice.CustomerID =
Customer.CustomerID)
WHERE (Customer.CustomerID = '?')

When i test it in the query generator everything works.
However when i add the following code to my vb form in order to populate the table with the correct data. The query will not work:

The system builds with no known errors however it does error when i try to open the page and takes me to a line of code in my form..

Me.InvoiceTableAdapter.FillBy(Me.GreenGrassdatabasemartynDataSet.Invoice, CustomerIDTextBox.Text)

The error is: Conversion from string "" to type 'Integer' is not valid.

I have checked in my database that they are both integers which is
correct.
I have looked through the propperties on the text box to ensure they are
correct and i have found no problems?

Any suggestions?

The error stems from the parameter you are passing. It stems from either of the following: 1)Try casting the text box contents to integer before actual passing and see what the result will be. It is reporting that the contents of the text box is not a valid integer datatype.
(2). Make sure you are not passing an emptiness to the adapter. i.e make sure your text box contains something.

Try this:

Me.InvoiceTableAdapter.FillBy(Me.GreenGrassdatabasemartynDataSet.Invoice, CInt(CustomerIDTextBox.Text))

Please get back to me.:cool:

I have generated some SQL code
SELECT Invoice.InvoiceID, Invoice.CustomerID, Invoice.RouteNumber,
Invoice.TreatmentType, Invoice.Information, Invoice.StreetAddress,
Invoice.Postcode,
Invoice.Invoicecost, Invoice.InvoiceDate
FROM (Invoice INNER JOIN
Customer ON Invoice.CustomerID =
Customer.CustomerID)
WHERE (Customer.CustomerID = '?')

When i test it in the query generator everything works.
However when i add the following code to my vb form in order to populate the table with the correct data. The query will not work:

The system builds with no known errors however it does error when i try to open the page and takes me to a line of code in my form..

Me.InvoiceTableAdapter.FillBy(Me.GreenGrassdatabasemartynDataSet.Invoice, CustomerIDTextBox.Text)

The error is: Conversion from string "" to type 'Integer' is not valid.

I have checked in my database that they are both integers which is
correct.
I have looked through the propperties on the text box to ensure they are
correct and i have found no problems?

Any suggestions?

You might need to set the string in the textbox to an integer. This is done something like this.

Dim CustID as Integer

CustID = val(CustomerIDTextBox.Text)

Me.InvoiceTableAdapter.FillBy(Me.GreenGrassdatabasemartynDataSet.Invoice, [B]CustID[/B])
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.