View Single Post
  #1   Report Post  
Mark Olbert
 
Posts: n/a
Default Sql Query: 255 character Limit

Situation:

Office Apps: Excel XP and Word XP

My .NET Windows.Forms app creates an Excel file using OLE Automation and populates that file with
data from a database. I then use MailMerge.OpenDataSource() to open the Excel file with the
following connection string and Sql command:

string connStg = "Provider=Microsoft.Jet.OLEDB.4.0;Password=\"\";Us er ID=Admin;Data Source=insert
file user-selected Excel data file with full path here;Mode=Read;Extended
Properties=\"HDR=YES;IMEX=1;\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet
OLEDBat";

string sqlStg = "SELECT * FROM `Sheet1$`";

These are based to OpenDataSource() as ref'd objects.

Problem:

There are actually two mailmerge operations I'm testing. The first succeeds, the second fails with
the infamous "255 character limit" exception. The length of connStg + sqlStg is 277 characters for
the first, successful merge and 290 characters for the second, failing merge. I'm not sure if those
character lengths are what Word is "seeing" on its end, as .NET uses Unicode and I'm not sure what
Word uses internally.

Any suggestions on how to resolve this situation?

- Mark

p.s. BTW, may I assume that whatever, ahem, person left a 255 character limit in the Word mailmerge
subsystem at least through Office XP has been summarily fired?