Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 March 23rd, 2004, 12:48 PM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting User Input to SmallDateTime

Hello.

I'm working on a form that passes user input of a date to a database & I'm getting an error "Syntax error converting datetime from character string."

I want to display a month & day on the form, so I have set up a textbox like this, which works great in displaying values form the database in this format - "January 19":

<asp:TextBox id="tbxDiscountEnds" Text='<%# DataBinder.Eval(Container.DataItem, "DiscountEnds", "{0:m}") %>' OnTextChanged="subTextChange" size="10" runat="server" />

The database has a field assigned the name "DiscountEnds" with data type datetime.

I am using a stored procedure to take the value passed from the form to update the database:

CREATE sp_Update
@DiscountEnds VarChar (10), ETC..
UPDATE TaxInfo
SET
DiscountEnds = CONVERT(DateTime, @DiscountEnds) ETC..
GO

& here is the update subfunction on the form:
Dim objDiscountEndsTextBox As Object
Dim objUpParameter26 As New SqlParameter("@DiscountEnds", SqlDbType.VarChar, 10)
objUpParameter26.Direction = ParameterDirection.Input
objDiscountEndsTextBox = objCountyRepeater.Items(intSelectedEntityIndex).Fi ndControl("tbxDiscountEnds")
objUpParameter26.Value = objDiscountEndsTextBox.Text
objUpConnection.Open()
objUpCommand.ExecuteReader()
objUpConnection.Close()

Any ideas why I'm getting these errors? I've tried many changes in the syntax but can't seem to hit the nail on the head.

Thanks,

Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
storing user input brainchild Javascript 2 March 1st, 2007 04:55 AM
Converting from character to smalldatetime x_ray SQL Server 2000 2 November 26th, 2005 06:01 AM
Converting user input - SmallMoney type saturdave ASP.NET 1.0 and 1.1 Basics 1 April 8th, 2004 08:16 PM
validating user input hosefo81 Javascript How-To 12 March 3rd, 2004 09:32 AM





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