Not Recognizing Column Name

Results 1 to 2 of 2

Thread: Not Recognizing Column Name

  1. #1
    Join Date
    Dec 1969

    Default Not Recognizing Column Name

    I’m using the function below to retrieve data from an Access database. It works fine when I sort on “category”. But for a different page, I need the same data sorted first on “category_no” then on “seq_no”. I’m getting the error message, “Cannot find column category_no.” on the following statement:<BR>dvwPhysTraits.Sort = "category_no, seq_no"<BR><BR>I removed the cached dataset that was sorted on “category” & allowed it to be recreated in case the different sort sequence was causing the problem, but that didn’t change anything. <BR><BR>This is the function:<BR>Function GetPhysQuest() as System.Data.DataView<BR>&#039;Retrieve physical categories & subcategories from database<BR>&#039;Return dataview<BR> Dim dstCompatibility as System.Data.DataSet, _<BR> conCompatibility as System.Data.OleDb.OleDbConnection, _<BR> dadCompatibility as System.Data.OleDb.OleDbDataAdapter, _<BR> dvwPhysQuest as System.Data.DataView, _<BR> strSQL as String, _<BR> strConnection as String<BR><BR> Dim connectionString as String = "Provider=Microsoft.Jet.OLEDB.4.0; " _<BR> & "Ole DB Services=-4; Data Source=C:My ASPNet Web SiteCompatibility.mdb"<BR><BR>&#039;Retrieve categories from database<BR> dstCompatibility = New System.Data.DataSet()<BR> conCompatibility = New System.Data.OleDb.OleDbConnection(connectionString )<BR><BR> Dim SQL as String<BR> strSQL = "SELECT a.category_no, a.category, b.category_no, b.seq_no," _<BR> & " b.subcategory FROM tbl_physical_categories a, tbl_physical_subcategories b" _<BR> & " WHERE a.category_no = b.category_no"<BR> dadCompatibility = New System.Data.OleDb.OleDbDataAdapter(strSQL,conCompa tibility)<BR> dadCompatibility.Fill(dstCompatibility, "PhysicalCategories")<BR><BR> &#039;Create dataview<BR> dvwPhysQuest = dstCompatibility.Tables("PhysicalCategories").Defa ultView()<BR> Return dvwPhysQuest<BR>End Function<BR>

  2. #2
    Join Date
    Dec 1969

    Default Alias one of the category_no columns

    It can&#039;t find a _unique_ category_no column, as you have two of them in your select.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts