Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #1 (permalink)  
Old April 12th, 2006, 06:29 AM
MDM MDM is offline
Authorized User
Join Date: Mar 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default stored procedure: time format/mismatch problem.

Hi everyone,

 I urgently need your help with the stored procedure. I intend to read in a number of values (time and day format), format it to the uk standard and then pass on.
Through the code below I carry submission date and current date as strings and then attempt to insert into the DB in relevant fields (that are datetime format, the us style).

I am getting the following error that is very straightforward, however I cant put my head ot it. Further comlication is my relative uneasy with the us/uk date format struggle.
Please, feel free to suggest constructive solutions.

Server Error in '/GT' Application.
String was not recognized as a valid DateTime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a valid DateTime.

Source Error:

Line 70: cmd.Parameters.Add(up2)
Line 71:
Line 72: Session("RequestID") = CType(cmd.ExecuteScalar, String)
Line 73: lblOrderID.Text = CStr(Session("RequestID"))
Line 74: cnn.Close()

line 72 is highlighted




 Calendar1.SelectedDate = Calendar1.TodaysDate

        Dim ST, SD, SDST As String
        ST = Format(TimeOfDay.ToLocalTime)
        SD = Format(Calendar1.TodaysDate, "dd/MM/yyyy,")
        SDST = SD & Space(1) & ST
        Session("ASDate") = SDST

Session("ADT") = txtDate.Text & Space(1) & txtTime.Text

---------------------------next page ---------------------------------------------------

        lblADT.Text = CStr(Session("ADT"))

        HiddenField1.Value = CStr(Session("ASDate"))

------------------------- following page ----------------------------------------------

Dim cnn As SqlConnection = _
             New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\ASPNETDB.MDF;User Instance=True;
Integrated Security=True; Trusted_Connection = Yes;")

        Dim cmd As New SqlCommand
        With cmd
            .Connection = cnn
            .CommandText = "insNewRequest"
            .CommandType = CommandType.StoredProcedure
        End With

        Dim up1 As New SqlParameter("@SubmissionDate", SqlDbType.DateTime)
        up1.Direction = ParameterDirection.Input
        up1.Value = CType(Session("ASDate"), String)

        Dim up2 As New SqlParameter("@RequiredDate", SqlDbType.DateTime)
        up2.Direction = ParameterDirection.Input
        up2.Value = CType(Session("ADT"), String)

        Session("RequestID") = CType(cmd.ExecuteScalar, String)
        lblOrderID.Text = CStr(Session("RequestID"))

---------------------------------- the insNewRequest stored procedure -------------------------------------------


@SubmissionDate datetime,
@RequiredDate datetime,

    Insert INTO [Requests](SubmissionDate,RequiredDate )
     VALUES (@SubmissionDate, @RequiredDate)

  #2 (permalink)  
Old April 12th, 2006, 03:42 PM
MDM MDM is offline
Authorized User
Join Date: Mar 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts

Anyone? I would appreciate your contribution as this is urgent!



Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure problem keyvanjan ASP.NET 2.0 Basics 2 June 3rd, 2007 09:27 PM
Problem in stored procedure hkec SQL Language 1 October 6th, 2006 02:29 PM
Stored Procedure Problem kwilliams SQL Server 2000 7 June 23rd, 2006 03:03 PM
Stored procedure problem dkspivey SQL Language 2 February 6th, 2006 01:44 PM
Problem In Stored procedure mistry_bhavin Oracle 1 October 11th, 2005 05:15 AM

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