Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert generates NULL error
Message
De
04/12/2006 16:43:02
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01174759
Message ID:
01174766
Vues:
10
>I have another .NET issue. I built a DBFUtil object that initializes the SelectCommand, InsertCommand, UpdateCommand, and DeleteCommand objects in a DataAdapter to all use the same VFPOLEDB connection. Everything works fine, and I can SELECT, INSER, UPDATE, and DELETE using a DataTable hooked to a DataGridView.
>
>But when I try to add a new record by entering a new row in the grid, I get NULL errors unless I fill in every field that is being added. There are no constraints on the DBF (it is a free table), and I know new rows are inserted properly if I fill everything in.
>
>I had the same issue with straight SELECT statements, and got around it by issuing a "SET NULL OFF" in the SelectCommand object using ExecuteNonQuery(). For SELECTs, I can have NULLs all over (e.g. when running LEFT JOINS), but if I run the same SET NULL OFF for InsertCommand and UpdateCommand as well, I am still getting NULL errors from the OleDb provider when adding or updating records involving NULLs.
>
>Obviously, I can get around this by making sure I don't have NULLs involved. *smile* But I was wondering if there was another way? Frankly, sometimes NULLs are very useful, as in having a logical field that can be true, false, or simply unanswered. I need to get NULLs working if I can, for creates, reads, updates, and deletes...

I adjusted my framework to populate the proper insert command based on the data dictionnary so all the fields are taking care of. By that, I also avoid any nulls in the table where all fields have a default value. I first tried to adjust the connection strings to tell the VFPOleDb to ignore nulls and things like that but that never worked. I have a InsertRow class that I an instantiating when I need to insert a record, I fill the fields that are only necessary and it does the rest.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform