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
|