0

I create a table in my Microsoft Access database in C# using the following code:

query= "CREATE TABLE test1( [city] CHAR(60),[street] CHAR(60))";
OleDbCommand cmd = new OleDbCommand(query, connection);
            result = cmd.ExecuteNonQuery();

All works fine. When I open the table in Microsoft Access I see a row with these 2 fields and with some layout. I write in the field "city" some text in Hebrew that might be more long that current layout of this field. When I go to the next field the text in field "city" is not visible. So I increase the layout of city field and I see that all text is not justified to left and to right, there are some spaces between right bound of column and the most right letter of the text. If I try in Design view to define property "Text Align" of this field as "Left" it does not help. But if I add a new field when I still work with this table in Access and write in Hebrew there is no such problem: the text is aligned to the left and it is visible when I go to other field. So my question: is there any possibility to solve this problem that is to make text be justified to the left in any case? I do not see any properties or methods that could help to define programmatically a layout of table. Also in environment of Access the layout is saved after any change (if user approves this) but I did not find any property where it is saved.

eug100
  • 177
  • 11
  • Sounds like you need to compare the two tables and fields. The easiest way to do that is to attempt to make them identical, in your two different ways. Then export them to text. You will then be able to quickly see the difference between the two. I use this program to export my entire project to text objects: https://github.com/joyfullservice/msaccess-vcs-integration – HackSlash Dec 15 '21 at 16:07
  • Does Access support unicode? It's a very old technology. You might be better off using SQL Server, and setting up the correct collation – Neil Dec 15 '21 at 16:15
  • @HackSlash: there is no 2 tables. I wok with one table. 2 fields were created in C# and the third one in MS Access. The field city was created with length 60, the third field Field3 was created in Access with the same length. I exported the table in text file. I see that city field contains many spaces after my text (it seems that there are 60 symbols) and Field 3 has exactly that text that I wrote withou additional spaces. – eug100 Dec 15 '21 at 16:40
  • @Neil: I work a lot with SQL Server, but in this case I need to work with MS Access. – eug100 Dec 15 '21 at 16:41
  • @Neil IIRC MS Access has a limited unicode supported characters but there are nasty work around. – Franck Dec 15 '21 at 16:58
  • @eug100 I am suggesting to make two tables. One made from within Access and one you generate with your code. Then export the tabledefs to text, not the values. Compare the tabledefs to see what properties are different between the two. – HackSlash Dec 15 '21 at 17:12
  • @Franck Not at all. Access is natively UTF-16. It's just that VB Projects and some VBA functions/libraries are not, but every character field and every string in Access is UTF-16. This issue is also unrelated to Hebrew characters, which are supported – Erik A Dec 15 '21 at 17:20
  • @ErikA I just recalled working on Access 2016 and having unicode issues and i was working with VBA so it must have been where the problem lies but we did manage work around. Are you aware if those issues are fix with Access 360 nowadays ? – Franck Dec 15 '21 at 17:33
  • @Franck You have to be specific about "unicode issues" since Access has been full UTF-16 since at least 2003. I've written [this Q&A](https://stackoverflow.com/q/55210315/7296893) for MsgBox that strangely is still in the local encoding, and have [this answer](https://stackoverflow.com/a/51949328/7296893) for working with unicode characters in the VB Project (which unfortunately is still local encoding), but that's all I encountered. – Erik A Dec 15 '21 at 17:45
  • @HackSlash: how can I export the tabledefs? I do not see such option in Access. – eug100 Dec 15 '21 at 17:45
  • 1
    Varchar or text instead of CHAR for field definition solves the problem – eug100 Dec 15 '21 at 19:24

0 Answers0