Trying to insert data

A

AMP

Hello,
I am trying to insert data with the following:
mee.Insert(5, currentUser.ProviderUserKey.ToString(),
x,"","","",DateTime.Now ,DateTime.Now ,DateTime.Now , DateTime.Now)

But get the following error:

The best overloaded method match for
'DataSet1TableAdapters.Picks1TableAdapter.Insert(int?, string, string,
string, string, string, System.DateTime?, System.DateTime?,
System.DateTime?, System.DateTime?)' has some invalid arguments

All allow nulls.
 
G

Gregory A. Beamer

I am trying to insert data with the following:
mee.Insert(5, currentUser.ProviderUserKey.ToString(),
x,"","","",DateTime.Now ,DateTime.Now ,DateTime.Now , DateTime.Now)

But get the following error:

The best overloaded method match for
'DataSet1TableAdapters.Picks1TableAdapter.Insert(int?, string, string,
string, string, string, System.DateTime?, System.DateTime?,
System.DateTime?, System.DateTime?)' has some invalid arguments

All allow nulls.

(DateTime?)DateTime.Now

Even better:

DateTime? now = (DateTime?)DateTime.Now;

That solves that part. The second part is what is x?

NOTE: This is just from the hip, but it seems DateTime? is a handled a
bit differently than int? and may require the conversion.

Peace and Grace,


--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
A

AMP

(DateTime?)DateTime.Now

Even better:

DateTime? now = (DateTime?)DateTime.Now;

That solves that part. The second part is what is x?

NOTE: This is just from the hip, but it seems DateTime? is a handled a
bit differently than int? and may require the conversion.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog:http://gregorybeamer.spaces.live.com

*******************************************
|      Think outside the box!             |
*******************************************

x is a string (I'm testing)
 
A

AMP

(DateTime?)DateTime.Now

Even better:

DateTime? now = (DateTime?)DateTime.Now;

That solves that part. The second part is what is x?

NOTE: This is just from the hip, but it seems DateTime? is a handled a
bit differently than int? and may require the conversion.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog:http://gregorybeamer.spaces.live.com

*******************************************
|      Think outside the box!             |
*******************************************

Why is there a ? after the int and DateTime, but not the strings?
 
C

Chris Dunaway

Why is there a ? after the int and DateTime, but not the strings?

The ? indicates that it is a nullable type. So DateTime? is the same
as Nullable<DateTime>. Strings don't need it because they are
reference types and are already nullable.

Chris
 
G

Gregory A. Beamer

Why is there a ? after the int and DateTime, but not the strings?

Strings are a clss and are nullable by default. An int, et al, are structs
and don't have nullability as a concept.

int? is actually a C# language feature to represent Nullable<int>, which is
a generic "wrapper" for nullable types.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top