Hi there,
I am sure this is really easy but I have a form that contains a number of textboxes and also a datagrid.
I have a textbox on the form called txtCustomerID which displays the primary key for tblCustomers and also I have another table called tblQuotes which has CustomerID as a FK.
What I would like is for the datagrid to be showing all quotes that relate to the customer.
This is my code.
Code:Private Sub FillDataGrids() Dim conn As New SqlClient.SqlConnection("Server = " & "nx6130" & _ "; Database = ActionGlass; " & _ "Integrated Security = sspi;") Dim ds As New DataSet Dim daQuotes As New SqlClient.SqlDataAdapter("SELECT tblQuotes.QuoteID,DateOfQuote,CustomerID FROM tblQuotes WHERE tblQuotes.CustomerID = '10' ", conn) Dim daOrders As New SqlClient.SqlDataAdapter("SELECT * from tblOrders WHERE condition = '" & txtCustomerID.Text & "'", conn) Dim daPayments As New SqlClient.SqlDataAdapter("SELECT tblPayments.PaymentID FROM tblPayments", conn) 'Dim daOrders As New SqlClient.SqlDataAdapter("SELECT * from tblOrders", conn) daOrders.Fill(ds, "tblOrders") daQuotes.Fill(ds, "tblQuotes") daPayments.Fill(ds, "tblPayments") grdInvoices.ReadOnly = True grdQuotes.ReadOnly = True grdPayments.ReadOnly = True grdInvoices.AllowUserToAddRows = False grdInvoices.DataSource = ds grdQuotes.DataSource = ds grdPayments.DataSource = ds grdInvoices.DataMember = "tblOrders" grdQuotes.DataMember = "tblQuotes" grdPayments.DataMember = "tblPayments" With grdQuotes ' .Columns("QuoteID").HeaderText = "Quote ID" ' .Columns("DateOfQuote").HeaderText = "Date Of Quote" End With End Sub
When I try run the above code I get an error message on the line
The error tells me SQLExpception was unhandled. Invalid column name 'condition'Code:daOrders.Fill(ds, "tblOrders")
Can anyone help.
Thanks
Shane
Can anyone show me what I need to do to enable what im trying to do.




Reply With Quote