hi,
the code you present is no generic at all, you have hardcoded both the
table name as well as the where clause
You do not especify it, but I think that you are getting this error in the
return statement
string RetValue=(string)Adapter.SelectCommand.ExecuteScalar();
It's because of the cast, there is no implicit cast of a DateTime to string
change it to this:
string RetValue= Adapter.SelectCommand.ExecuteScalar().ToString();
cheers,

Signature
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
> Hello,
>
[quoted text clipped - 34 lines]
> Thanks
> Paul
Paul Yanzick - 28 Feb 2005 16:35 GMT
Hello Ignacio,
You are correct, it isn't a totally generic function; actually it is generic
for this table... When the function is called, I specify the field I want
and the IDkey of the record that I receive via another method... at least
that is the plan.
Thanks for your help, that worked! Using (string) in front of the other
values work for the other items, why does it not work for DateTime?
Thanks
Paul
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
> hi,
>
[quoted text clipped - 52 lines]
>> Thanks
>> Paul
Paul,
This is typical for the SQLparameter.
Then the date when you supply it as DateTime will normally be done right.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemdatasqlclientsqlcommandclassparameterstopic.asp
On this page is the parameter better desctibed.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemdatasqlclientsqlparameterclasstopic.asp
I don't see where that dataadapter is for in your code
SQLCommand.ExecuteScalar
Should in my idea be enough.
I hope this helps?
Cor
Cor Ligthert - 28 Feb 2005 16:31 GMT
Paul,
I forgot, and you need probably the Convert.ToString or DateTime.Parse when
the value you get is a datetime.
Cor
Paul Yanzick - 28 Feb 2005 16:38 GMT
Cor,
I had added the SqlDataAdapter as something to try in resolving this
issue... It had actually resolved a problem I had when trying to get an
identity after writing to the table.
It seems that Command.ExecuteScalar().ToString() worked for me. I
appreciate the links and will look through thouse.
Thanks
Paul
> Paul,
>
[quoted text clipped - 16 lines]
>
> Cor