问题
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:
- only the first 255 characters of each field will be compared, and
- the query might be slow to execute.
来源:https://stackoverflow.com/questions/24733678/cannot-join-on-memo-ole-or-hyperlink-object