Results 1 to 12 of 12

Thread: Syntax error (Resolved)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    16

    Resolved Syntax error (Resolved)

    "Syntax error converting datetime from character string"

    i get this error when i am trying to pass 2 dates as parameters to a stored procedure in sql server

    thanks for any help in advance
    Last edited by Mystiquemint; Jun 21st, 2005 at 05:00 AM.
    I respect Faith, but doubts are what get me educated

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Syntax error

    It would be better if you would post your code.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Syntax error

    dates to a data base have to be in specific format, for access it is mm/dd/yy
    i am not sure about sql, maybe the same or maybe yyyy/mm/dd

    pete

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    16

    Re: Syntax error

    .Parameters.Append .CreateParameter("@DateFrom", adVarChar, adParamInput, 25, CStr(MyArgs(1)))
    .Parameters.Append .CreateParameter("@DateTo", adVarChar, adParamInput, 25, CStr(MyArgs(2)))

    'Setup connection details and open connection to dB
    Set mycon = New ADODB.Connection
    mycon.ConnectionString = "File Name=" & App.Path & UDL_FILENAME
    mycon.Open

    Set .ActiveConnection = mycon

    'Run command
    .Execute

    no matter how i pass these variables, i am getting the same error.
    i mean i tried with the parameter datatype as adDate. no luck
    I respect Faith, but doubts are what get me educated

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Syntax error

    What is CStr(MyArgs(2))?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    16

    Re: Syntax error

    date selected by the user from a datepicker
    I respect Faith, but doubts are what get me educated

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Syntax error

    Why are you converting them to string with CSTR?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    16

    Re: Syntax error

    i am just trying various combinations.............
    even if i send the parameters as it is (with out converting) still i am getting the same error
    I respect Faith, but doubts are what get me educated

  9. #9
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Syntax error

    What type does the stored procedure use for the input parameters?
    If possible, just change them to DateTime, so you can pass the parameters as dates, and not as text.

    Your code needs a change too.

    VB Code:
    1. .Parameters.Append .CreateParameter("@DateFrom", adDate, adParamInput, 25, MyArgs(1))
    2. .Parameters.Append .CreateParameter("@DateTo", adDate, adParamInput, 25, MyArgs(2))
    Frans

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    16

    Re: Syntax error

    well i tried that. didnt work. still the same error
    I respect Faith, but doubts are what get me educated

  11. #11
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Syntax error

    Can you post the code of the stored procedure?
    Frans

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    16

    Resolved Re: Syntax error

    finally, resolved. Thank you everybody for your help & time.
    I respect Faith, but doubts are what get me educated

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width