• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 498
  • Last Modified:

DataSet Insert Null Value to Row

Hello

I have a Dataset that I want to programitically add a record to.  I want to add a null value for some of the fields but get an "Invalid Arguement" error when I try.

This works:
myDataset.myTable.AddmyTableRow(myID, myDate, myInt);

This does not work:
myDataset.myTable.AddmyTableRow(myID, null, null);

This does not work:

myDataset.myTable.AddmyTableRow(myID, "", "");

Open in new window

0
doddwell
Asked:
doddwell
1 Solution
 
jdavistxCommented:
It would look like AddmyTableRow is setup like this?

public static void AddmyTableRow(this DataTable dt, int id, DateTime date, int i)
{
   //...
}

Open in new window


If you want to be able to send null values to those, then you need to make them Nullable objects.  Using the below, you could pass a DateTime and integer value that are delcared as nullable.

public static void AddmyTableRow(this DataTable dt, int id, DateTime? date, int? i)
{
   //...
}

Open in new window

0
 
doddwellAuthor Commented:
My Code actually looks like this:

public myTableRow AddmyTableRow(int myID, System.DatetTme myDate, int myValue)

So I changed it to
public myTableRow AddmyTableRow(int myID, System.DatetTme? myDate, int? myValue)

Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now