Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 11th, 2006, 03:16 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default date fiels insertation problem

hi...

my form has a text box which displays system date.

i am inserting date into MS SQL Server from this date textbox.

but it displays me error..

String was not recognized as a valid DateTime.
Line 154: myCommand1.ExecuteNonQuery()


i have written code as

myCommand1.Parameters.Add(New SqlParameter("@date", SqlDbType.DateTime, 8))

myCommand1.Parameters("@date").Value = FormatDateTime(datetxt.Text, DateFormat.GeneralDate)

and also tried to change date format with many other ways.

how should i solve this problem?

i also want to take time form a user with the help of web form and want to store it in other field called 'timein' and 'timeout'.....


 
Old March 7th, 2006, 06:36 AM
Authorized User
 
Join Date: Feb 2006
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there:
i had probably the same problem but i will guid you if i can.
try the following script
declare a variable:

currentdate as date
currentdate = Date.Today.ToLongDateString

Mycommand1.parameters.Add(new sqlParameter("@date", sqldbtype.datetime)).value= currentdate

i don't think you should include 8. what i understand is that you only allowing eight characters to be entered into your database. and that's not correct because the date have 10 characters. count this 12/12/2006.

try and tell me what happen.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Problem kuku SQL Server 2000 4 September 7th, 2005 08:38 PM
opening other fiels? vb certified Pro VB.NET 2002/2003 5 June 14th, 2005 05:30 PM
Date Problem. rupen Classic ASP Basics 3 June 3rd, 2005 09:58 AM
Multiple calulated fiels in one query? fdoosey Access 1 February 15th, 2005 09:17 AM
Date problem acko ASP.NET 1.x and 2.0 Application Design 3 January 14th, 2004 05:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.