Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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!




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 07:36 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.