P
Peter W Johnson
Hi Guys,
I have a VB .NET application that uses Access as the database. I
have one query (qryInvoiceNumbers) which creates a join on the ColumnName
InvoiceNumber in each of three tables using the same columnname
(tblTaxInvoice, tblPayments and tblTransactions). The tblTaxInvoice table
contains invoicenumbers in all rows, the other two tables do not.
As you can see in the following code I can differentiate between the
columnname in the different tables of the query in the select statement but
not in the setting of the variable InvoiceNumber. If is use
dsMasterInvoice.Tables(0).Rows(i)("tblTaxInvoice.InvoiceNumber") I get an
error saying that tblTaxInvoice.InvoiceNumber is not part of the dataset
MasterInvoice.
I do not want to change the table column names as that will require
significant modification to the main code.
Code follows:
mysql = "SELECT * FROM qryInvoiceNumbers WHERE
Left(tblTaxInvoice.InvoiceNumber, 2) = 'AP' ORDER BY
tblTaxInvoice.InvoiceNumber"
daMasterInvoice = New Odbc.OdbcDataAdapter(mysql, myconnection)
dsMasterInvoice = New DataSet
daMasterInvoice.Fill(dsMasterInvoice, "MasterInvoice")
Dim NoOfInvoices As Integer
NoOfInvoices = dsMasterInvoice.Tables(0).Rows.Count
Dim InvoiceNumber As String
For i = 0 To NoOfInvoices - 1
InvoiceNumber =
dsMasterInvoice.Tables(0).Rows(i)("InvoiceNumber")
'blah blah blah
Next
Code finishes:
Any ideas on how I can overcome this? Can I temporarily change the column
name programmatically?
Cheers
Peter
I have a VB .NET application that uses Access as the database. I
have one query (qryInvoiceNumbers) which creates a join on the ColumnName
InvoiceNumber in each of three tables using the same columnname
(tblTaxInvoice, tblPayments and tblTransactions). The tblTaxInvoice table
contains invoicenumbers in all rows, the other two tables do not.
As you can see in the following code I can differentiate between the
columnname in the different tables of the query in the select statement but
not in the setting of the variable InvoiceNumber. If is use
dsMasterInvoice.Tables(0).Rows(i)("tblTaxInvoice.InvoiceNumber") I get an
error saying that tblTaxInvoice.InvoiceNumber is not part of the dataset
MasterInvoice.
I do not want to change the table column names as that will require
significant modification to the main code.
Code follows:
mysql = "SELECT * FROM qryInvoiceNumbers WHERE
Left(tblTaxInvoice.InvoiceNumber, 2) = 'AP' ORDER BY
tblTaxInvoice.InvoiceNumber"
daMasterInvoice = New Odbc.OdbcDataAdapter(mysql, myconnection)
dsMasterInvoice = New DataSet
daMasterInvoice.Fill(dsMasterInvoice, "MasterInvoice")
Dim NoOfInvoices As Integer
NoOfInvoices = dsMasterInvoice.Tables(0).Rows.Count
Dim InvoiceNumber As String
For i = 0 To NoOfInvoices - 1
InvoiceNumber =
dsMasterInvoice.Tables(0).Rows(i)("InvoiceNumber")
'blah blah blah
Next
Code finishes:
Any ideas on how I can overcome this? Can I temporarily change the column
name programmatically?
Cheers
Peter