Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trouble with remote view varchar field in grid
Message
From
28/02/2018 18:52:40
 
 
To
28/02/2018 15:30:15
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01658476
Message ID:
01658491
Views:
47
>>>>Hi, I'm beginning to code a small client-server project. I'm using SQL Server 2012 as a back-end and decided to use Varchar fields in both SQL Server and VFP. I developed the first entry form and began to test it. I was adding records to a grid, entering and saving code and description filelds. All was fine until I realized that I had to modify the description field with a longer string, I tried and it did not let me enter more characters than the original length. The field is from a view which is VARCHAR(30) The properties of the textbox are:
>>>>
>>>>Format="F"
>>>>MaxLength=30
>>>>
>>>>I tried changing the format property to an empty string, it did not work, then tried changing MaxLength to 0, it did not work either. Anyone can help me please? Oh, I tried the same with the code field and it behaves the same, connot beyond the original 3-char length although the length of the varchar field is 5.
>>>
>>>Are you able to enter longer strings in the SQL Server table itself using SSMS - "Edit top 200 rows" or a query?
>>>
>>>If you can there's some issue with whatever framework you're using. Some frameworks have metadata which you may have to manually adjust or refresh if you change underlying tables or views. Usually you have to do this the "framework way" - "fighting" the framework usually doesn't work.
>>
>>Thanks. Yes, I can enter longer strings in SSMS. But I'm using plain VFP textboxes in a grid, so I guess there's some property in VFP that makes it behave like that.
>
>Did you rebuild or update the VFP view after changing the SQL Server table?

I found the solution from the VFP9's help. From the "Format property" topic and related to the "F" value function it is noted:

"When you drag a field with Varbinary type to a form or when you drag a Grid control to a form and create TextBox controls for columns with Varbinary type, the following occur:
- Format property is set to "F".
- MaxLength property is set to the maximum length multiplied by 2 for the Varchar field.
- InputMask property is filled with "H" up to the value of the MaxLength property."

Although when you drag a grid control and create textbox controls for columns with VarChar type, VFP just sets the Format property of the textbox to an "F".

What I did was to fill the MaxLength property with the length of the varchar field (in my case 30) and then finally, fill the InputMask property with 30 "!" characters (in my case I want to enter the letters in uppercase, that's why the "!" character). or you could just use =REPLICATE("!", 30). And it worked as expected.

The "!" characters in the InputMask did the trick. Note that this is only necessary when the textbox IS IN a grid column.
Previous
Reply
Map
View

Click here to load this message in the networking platform