Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Store a Date

Author  Topic 

Beady999
Starting Member

4 Posts

Posted - 2009-04-02 : 06:12:56
Hi,
please bear with me, I'm pretty new with SQL and C#.

I just want to store a date in an SQL database (field is datetime).

That's all.

The user types in 23/11/2009 or whatever and I want to be able to store that, as a date, in my database.

I've been searching the web and it appears that nobody else in the entire world wants to do just that

Can somebody please give me a clue.

Regards,
Bernard D

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-02 : 06:23:29
Make the date parameter to your stored procedure as datetime.
Create a command object in your code. Create a parameter of type datetime and use the value of the datetime variable in your code.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Beady999
Starting Member

4 Posts

Posted - 2009-04-02 : 06:55:10
quote:
Originally posted by Peso

Make the date parameter to your stored procedure as datetime.
Create a command object in your code. Create a parameter of type datetime and use the value of the datetime variable in your code.



E 12°55'05.63"
N 56°04'39.26"




Thanks for your quick response. Unfortunately the clue you provided is a bit cryptic for me.
I'm not using a stored procedure ( I don't think).
I have a rather long command, in the format @"UPDATE assignee SET forename = '" + Request.Form["ctl00$mainBody$forename"] + "' WHERE ID = " + Request.Form["ctl00$mainBody$ID"] etc."

How would I create a parameter? and where would it go?

I've tried using cast and convert and just get errors.

Regards,
Bernard D
Go to Top of Page
   

- Advertisement -