|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Smalldatetime problem during INSERT to DBi'm using VB.NET and SQL Server 2005. I have an editbox(mask : dd/mm/yyyy). And i want to insert it to table. My table's column is smalldatetime. when i'm insert it, DB Column's value is being 01/01/1900 00:00:00. But i want for example : 12/05/1969 (dd/mm/yyyy)... But i can't this. MY CODE.... screen's edit box : SCR_BIRTHDATE.text (Mask is : __/__/____) My SQL statement : sqlcmd.commandtext= _ "INSERT INTO members ( etc.... MEM_BIRTHDATE .... etc) VALUES (........etc" & SCR_BIRTHDATE.text & ".....etc )" If you can help me, i'm happy... Best Regards, HALDUN NAMLI haldunn wrote:
Show quote > Hi all from Turkey. Never insert parameters that way. Use the ADO parameters collection.> i'm using VB.NET and SQL Server 2005. I have an editbox(mask : dd/mm/yyyy). > And i want to insert it to table. My table's column is smalldatetime. when > i'm insert it, DB Column's value is being 01/01/1900 00:00:00. But i want for > example : 12/05/1969 (dd/mm/yyyy)... But i can't this. > > MY CODE.... > > screen's edit box : SCR_BIRTHDATE.text (Mask is : __/__/____) > > My SQL statement : > > sqlcmd.commandtext= _ > "INSERT INTO members ( etc.... MEM_BIRTHDATE .... etc) > VALUES > (........etc" & SCR_BIRTHDATE.text & ".....etc )" > Example at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlCommandClassParametersTopic.asp If you avoid passing dates as strings then you won't have any problem but if you must do so then specify the date in the form "19690512" (year, month, day, no separators). -- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx -- |
|||||||||||||||||||||||