Cannot join on Memo, OLE, or Hyperlink Object

爱⌒轻易说出口 提交于 2020-01-03 06:37:06

问题


Database: MS-Access

These are my database tables and columns.

Table: proje

Field Name     Type
-------------  -----------------------
id             Integer(Auto Increment)
projeAdi       Long Text
sirketAdi      Long Text

Table: calisan

Field Name     Type
-------------  -----------------------
id             Integer(Auto Increment)
gun            Date/Time
isTanimi       Long Text
kulID          Integer
basSaat        Date/Time
bitisSaat      Date/Time
proje          Long Text
istipi         Long Text

Sql query:

sorgu.Connection = baglanti;
baglanti.Open();    
sorgu.CommandText = "SELECT * FROM calisan INNER JOIN proje ON proje.projeAdi = calisan.proje;";
oku = sorgu.ExecuteReader();

I get the error

Cannot join on Memo, OLE, or Hyperlink Object (proje.projeAdi=calisan.proje)

How can I work around this limitation?


回答1:


As the error message states, you cannot use Memo fields (called "Long Text" fields in Access 2013) directly in a JOIN, so

cmd.CommandText =
        "SELECT * FROM calisan " +
        "INNER JOIN proje ON proje.projeAdi = calisan.proje";

won't work. You can use

cmd.CommandText =
        "SELECT * FROM calisan " +
        "INNER JOIN proje ON Left(proje.projeAdi,255) = Left(calisan.proje,255)";

with the following caveats:

  1. only the first 255 characters of each field will be compared, and
  2. the query might be slow to execute.


来源:https://stackoverflow.com/questions/24733678/cannot-join-on-memo-ole-or-hyperlink-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!