• Welcome, Guest. Please login.
 
October 21, 2019, 03:16:12 am

News:

Welcome to the SQLitening support forums!


-13 Invalid Column name or number

Started by Marc Van Cauwenberghe, January 28, 2012, 07:23:07 am

Previous topic - Next topic

Marc Van Cauwenberghe

Hello all,

Seem to be getting the above mentioned error, but I do not know why. I have pinpointed it but do not know what to do with it.
I have 2 tabels:

<'KlantAfspraken' is duch for 'CustomerApointments'>
CREATE TABLE [KlantAfspraken] (
  [Id] INTEGER PRIMARY KEY,
  [KlantId] INTEGER,
  [DateTime] LARGEINT,
  [Onderwerp] CHAR(512),
  [AfspraakGemaaktOp] CHAR(12),
  [AfspraakVia] CHAR(1),
  [Uitkomst] CHAR(1),
  [UitkomstNota] CHAR(255),
  [Id2] INTEGER);

<'Klant' is 'Customer'>
CREATE TABLE [Klant] (
  [Id] INTEGER PRIMARY KEY,
  [Naam] CHAR(30),
  [Straat] CHAR(30),
  [Postnummer] CHAR(4),
  [Woonplaats] CHAR(15),
  [Telefoon] CHAR(20),
  [Fax] CHAR(20),
  [Telefoon2] CHAR(20),
  [GSM] CHAR(20),
  [Email] CHAR(40),
  [BTWNr] CHAR(20),
  [Referentie] CHAR(10),
  [Soort] CHAR(3));

The following query gives the error:
sSQL = " SELECT [Klant].[Id], [Klant].[Naam], [Klant].[Straat], [Klant].[Postnummer], " & _
          "   [Klant].[Woonplaats], [Klant].[Telefoon], [Klant].[Fax], " & _
          "   [KlantAfspraken].[Id], [KlantAfspraken].[KlantId], " & _
          "   [KlantAfspraken].[AfspraakGemaaktOp], [KlantAfspraken].[AfspraakVia], " & _
          "   [KlantAfspraken].[Uitkomst], [KlantAfspraken].[UitkomstNota], " & _
          "   [Klant].[Telefoon2], [Klant].[GSM] " & _         
          " FROM [Klant] INNER JOIN " & _
          "   [KlantAfspraken] On [KlantAfspraken].[KlantId] = [Klant].[Id] " & _
          " WHERE ([KlantAfspraken].[DateTime] >= 20120128000000 And " & _
          "   [KlantAfspraken].[DateTime] < 20120129000000) "       
   lRC = slSelAry (sSQL , g_aKlantAfspraak())


This query will run in SQLite Expert Professional!!!
When I remove [KlantAfspraken].[Id] from the query the code will run.
When I rename [KlantAfspraken].[Id] to [KlantAfspraken].[Id2] and rename the field in the table it runs in code.
Is there a restriction on using 2 identical fieldnames in a query even if the table names are included?

Thanks for any help.
Marc

Marc Van Cauwenberghe

OK,
seems that this topic has been writen about before.
STFF!!!
:-[ :-[ :-[