Link to home
Start Free TrialLog in
Avatar of Nugs
Nugs

asked on

DataTable.Insert and null values.

Hey there guys,
I am trying to do a insert into the database used the insert property generated by my xsd in visual studio.

CustomerData.Insert(FName, LName, BillAddress, BillCity, BillState, BillZip, Phone, CompName, Email, null, null, null, null, null, 0);

As you can see i am trying to pass null values on some of the comulns. The database allows nulls in these fields, the columns in the TableAdapter in my xsd file allows nulls, the AllowDBNull property of these fields is set to true. yet i am still getting a error when trying to pass these nulls.
------------------------------------------------------------------------------------------
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: FLD_COMMENTS
Source Error:

Line 7258:            }
Line 7259:            if ((FLD_COMMENTS == null)) {
Line 7260:                throw new System.ArgumentNullException("FLD_COMMENTS");
Line 7261:            }
Line 7262:            else {
---------------------------------------------------------------------------------------

Am i missing something here?

Nugs
ASKER CERTIFIED SOLUTION
Avatar of surajguptha
surajguptha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nugs
Nugs

ASKER

MSDN does not say that:
http://msdn2.microsoft.com/en-us/library/ms364060(vs.80).aspx

" The EmployeeID and OrderDate columns are both type Nullable because the corresponding columns in the Northwind database allow nulls. You can call the Insert function passing Nothing (null in C#) in the place of type-safe parameters instead of setting a separate property or using another bulky mechanism to indicate that the fields are null. "
Avatar of Nugs

ASKER

Something wierd was happening here, i do not thin the changes and updates to my XSD file were being saved but i was able to fix this and am able to pass null as a value into these fields

CustomerData.Insert(FName, LName, BillAddress, BillCity, BillState, BillZip, Phone, CompName, Email, null, null, null, null, null, 0);

thanks for the input guys

Nugs