where clause with date (asp.net - vb)

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default where clause with date (asp.net - vb)


    Hi,

    I try to execute request on a ms-access database but I have a problem
    with date.
    the "myDate" field's format is "date/time"
    my request is:

    SELECT myCode, myStuff, myDATE FROM myTable WHERE myDate = #05/21/2004#

    in ms-access interface, it works fine !
    I get real good lines but when I try to execute in my asp.net vb page,
    I get "internal automation error" without any other information.

    Requests without date stuff inside works, in both asp and access even
    with a lot of lines in result, so it's not a timeout problem.

    executing request with
    "where myDate = #05/21/2004# "
    "where myDate LIKE #05/21/2004# "
    "where myDate = #05/21/2004 00:00:00# "
    "where myDate LIKE #05/21/2004 00:00:00# "
    with " # " or " ' " gives me an error

    If I change date delimiters to " ' ", I also get an error.

    I don't know how to get out of that !

    Thanks in advance for any tips !

    --yannick--
    no direct email reply : fake address
    Yannick Guest

  2. Similar Questions and Discussions

    1. #40218 [NEW]: Add Else clause to while
      From: jbailey at raspberryginger dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug...
    2. Using IN in a WHERE clause
      I'm trying to use IN in a WHERE clause as follows: idx_res.city IN ('#session.s_city#') The value of session.s_city is 'highlands ranch, lone...
    3. CF MX 6 WHERE Clause
      Hi everyone! I keep getting the following error when I submit an update form for processing Macromedia] Too few parameters. Expected 1. The error...
    4. connect by clause
      i have written this query on test database works fine but when we transfered both tables and the query to production we are getting two different...
    5. Using variable in From clause
      I want to write a T-Sql script that will cycle through all of the tables in a database and write the number of records in each table. I have the...
  3. #2

    Default Re: where clause with date (asp.net - vb)

    * Yannick <popeye@nowhere.com> scripsit:
    > I try to execute request on a ms-access database but I have a problem
    > with date.
    > the "myDate" field's format is "date/time"
    > my request is:
    >
    > SELECT myCode, myStuff, myDATE FROM myTable WHERE myDate = #05/21/2004#
    >
    > in ms-access interface, it works fine !
    > I get real good lines but when I try to execute in my asp.net vb page,
    > I get "internal automation error" without any other information.
    >
    > Requests without date stuff inside works, in both asp and access even
    > with a lot of lines in result, so it's not a timeout problem.
    >
    > executing request with
    > "where myDate = #05/21/2004# "
    > "where myDate LIKE #05/21/2004# "
    > "where myDate = #05/21/2004 00:00:00# "
    > "where myDate LIKE #05/21/2004 00:00:00# "
    > with " # " or " ' " gives me an error
    >
    > If I change date delimiters to " ' ", I also get an error.
    Post the code you use tho send the command.

    --
    Herfried K. Wagner [MVP]
    <URL:http://dotnet.mvps.org/>
    Herfried K. Wagner [MVP] Guest

  4. #3

    Default Re: where clause with date (asp.net - vb)

    Hi,

    I can't seam to reproduce your error. I tried all your sql statements
    with the northwind database and got no errors.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    If Not Me.IsPostBack Then
    BindDataToGrid()
    End If
    End Sub

    Private Sub BindDataToGrid()
    Dim strConn As String
    Dim conn As OleDb.OleDbConnection
    Dim daOrders As OleDb.OleDbDataAdapter
    Dim ds As DataSet

    ds = New DataSet
    strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
    strConn &= "Data Source = C:\Northwind.mdb;"

    conn = New OleDb.OleDbConnection(strConn)

    daOrders = New OleDb.OleDbDataAdapter("Select OrderID,
    OrderDate, ShipVia from Orders where OrderDate LIKE #01/01/1998
    00:00:00#", conn)

    ds = New DataSet

    daOrders.Fill(ds, "Orders")

    DataGrid1.DataSource = ds.Tables("Orders")
    DataGrid1.DataBind()
    End Sub

    Ken
    -------------------

    "Yannick" <popeye@nowhere.com> wrote in message
    news:MPG.1b43c4a7e1a49540989682@news.online.net:
    > Hi,
    >
    > I try to execute request on a ms-access database but I have a problem
    > with date.
    > the "myDate" field's format is "date/time"
    > my request is:
    >
    > SELECT myCode, myStuff, myDATE FROM myTable WHERE myDate = #05/21/2004#
    >
    > in ms-access interface, it works fine !
    > I get real good lines but when I try to execute in my asp.net vb page,
    > I get "internal automation error" without any other information.
    >
    > Requests without date stuff inside works, in both asp and access even
    > with a lot of lines in result, so it's not a timeout problem.
    >
    > executing request with
    > "where myDate = #05/21/2004# "
    > "where myDate LIKE #05/21/2004# "
    > "where myDate = #05/21/2004 00:00:00# "
    > "where myDate LIKE #05/21/2004 00:00:00# "
    > with " # " or " ' " gives me an error
    >
    > If I change date delimiters to " ' ", I also get an error.
    >
    > I don't know how to get out of that !
    >
    > Thanks in advance for any tips !
    >
    > --yannick--
    > no direct email reply : fake address
    >
    --
    Outgoing mail is certified Virus Free.
    Checked by AVG Anti-Virus ([url]http://www.grisoft.com[/url]).
    Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004


    Ken Tucker [MVP] Guest

  5. #4

    Default Re: where clause with date (asp.net - vb)

    > SELECT myCode, myStuff, myDATE FROM myTable WHERE myDate = #05/21/2004#
    >
    > in ms-access interface, it works fine !
    > I get real good lines but when I try to execute in my asp.net vb page,
    > I get "internal automation error" without any other information.
    You might think about using a safe date format, e.g. 2004-05-21.
    > "where myDate LIKE #05/21/2004# "
    No, don't ever treat a date column like a string. It is not stored the way
    it looks!
    > If I change date delimiters to " ' ", I also get an error.
    That's because you're telling Access you're looking for a string. Access
    expects # for date delimiters.

    Followups set to the dotnet group only. This is not related to ASP.

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)


    Aaron [SQL Server MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139