Reassigning the data source from Excel to SQL server

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
mma
Newcomer
Posts: 3
Joined: Wed Sep 05, 2018 3:21 pm

Reassigning the data source from Excel to SQL server

Post by mma » Fri Sep 07, 2018 1:59 pm

I use SDK.NET.Interface in C#.

I am given a lot of .lbl files, each designed with an Excel data source, but I want to use them with an SQL data source instead. I managed to make this when the name of the field of the SQL table is the same as the field name used at design time. This requires only

  1. to change the connection string from

    Code: Select all

    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\....xls;Extended Properties="Excel 8.0;HDR=YES;IMEX=1"
    to

    Code: Select all

    Provider=SQLNCLI10;SERVER=JUTAS\\SQLEXPRESS;DATABASE=SPEDSTORE;UID=sa;Pwd=the-real-password
  2. label.DataSets[0].CustomSql to the desired SQL select command
  3. setting IsCustomSql=true.
The name of the table has no relevance.

But how can I resolve the situation, when the column name in the SQL table is different from the field name in the old Excel file?

The difficulty is that both label.DataSets[0].Fields[0].FieldName and label.DataSets[0].Fields[0].FieldAlias properties are read-only, and I don't see what should (and can I) change to use my SQL column name. I don't find any clue nor in the internet, nor in the NiceLabel documentation.

Any help would be greatly appreciated.

Post Reply