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.ArgumentNullExcepti on: Value cannot be null.
Parameter name: FLD_COMMENTS
Source Error:
Line 7258: }
Line 7259: if ((FLD_COMMENTS == null)) {
Line 7260: throw new System.ArgumentNullExcepti on("FLD_CO MMENTS");
Line 7261: }
Line 7262: else {
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -
Am i missing something here?
Nugs
I am trying to do a insert into the database used the insert property generated by my xsd in visual studio.
CustomerData.Insert(FName,
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.ArgumentNullExcepti
Parameter name: FLD_COMMENTS
Source Error:
Line 7258: }
Line 7259: if ((FLD_COMMENTS == null)) {
Line 7260: throw new System.ArgumentNullExcepti
Line 7261: }
Line 7262: else {
--------------------------
Am i missing something here?
Nugs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
CustomerData.Insert(FName,
thanks for the input guys
Nugs
ASKER
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. "