Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Thursday, March 22, 2012

DateTime.Now expression expected problem

Hi - I'm using VWD, VB, and created a dataset/tableadapter to insert a record into a SQL Express database. The database has a couple of columns, but specifically a Datetime column.

Using the default insert created, I have the following code:

Dim da as New partyDetailsTableAdapters.partyDetailsTableAdapter
Profile.partyid = da.Insert(Profile.UserName, tbName.Text, DateTime.Now)

The compiler throws an error though, saying 'Expression expected' - and it squiggles an underline under the closing bracket after DateTime.Now - I have no problem if I'm trying to update a record using:

Dim da as New partyDetailsTableAdapters.partyDetailsTableAdapter
Dim pd as partyDetails.partyDetailsDataTable
pd = da.GetPartyDetailsByID(Profile.partyid)
da.Update(Profile.UserName, tbName.text, DateTime.Now, Profile.partyid, Profile.partyid)

Have I an error in my Insert section?

Thanks for any help,

Mark

Look at what the functions da.Insert and ds.Update are expecting as their arguments.

Maybe daInsert is expecting the date as a string instead of a DateTime object

Monday, March 19, 2012

Datetime parameter

I have a Datetime parameter from a dataset. It also shows the time but I
only need the date, is it possible somehow to change how it displays the
parameter. As what I can see it is only possible to choose datetime format.
I tried to convert it like this convert(datetime,period,105) as dateonly and
then use this field but it shows exactly the same !
Jackin the report, in the expression field , where you place the datetime field,
go to properties of the textbox,on the right hand side, go to standard
formatting, click on the date and select the format u want.
or u can go custom formatting too.
Hope This Helps
RP
"Jack Nielsen" wrote:
> I have a Datetime parameter from a dataset. It also shows the time but I
> only need the date, is it possible somehow to change how it displays the
> parameter. As what I can see it is only possible to choose datetime format.
> I tried to convert it like this convert(datetime,period,105) as dateonly and
> then use this field but it shows exactly the same !
> Jack
>
>