Results 1 to 5 of 5

Thread: SQL query

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Unhappy SQL query

    Hi guys
    Well I’m developing an app which uses a db in which in table “A” I have field, “DATE” as Date/time field type. And some other fields which are string and long type. Now I want to do a SQL query on this table. And use the SQL statement in the following code to open the desired recordset:
    SQLstatment= “SELECT A.DATE , A.Name ,A.UserID FROM A where A.DATE=’somedate’”
    Set rs=db.Recordset(SQLstatment)
    But vb returns error: Type mismatch.
    I also tried the following method:
    Dim datDate as date
    datDate = now
    SQLstatment= “SELECT A.DATE , A.Name ,A.UserID FROM A where A.DATE=” & datDate
    But again another error. I don’t know how to make this query that the “WHERE” section asks about a “date type” field. Can anybody help?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: SQL query

    Originally posted by mrdj1002
    Hi guys
    Well I’m developing an app which uses a db in which in table “A” I have field, “DATE” as Date/time field type. And some other fields which are string and long type. Now I want to do a SQL query on this table. And use the SQL statement in the following code to open the desired recordset:
    SQLstatment= “SELECT A.DATE , A.Name ,A.UserID FROM A where A.DATE=’somedate’”
    Set rs=db.Recordset(SQLstatment)
    But vb returns error: Type mismatch.
    I also tried the following method:
    Dim datDate as date
    datDate = now
    SQLstatment= “SELECT A.DATE , A.Name ,A.UserID FROM A where A.DATE=” & datDate
    But again another error. I don’t know how to make this query that the “WHERE” section asks about a “date type” field. Can anybody help?
    are you using ADO? if so do you have a connection set up??? i am not so sure your sql statement is wrong as your method for opening it

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Re: Re: SQL query

    No I'm using DAO and i have opend the db before, useing:
    set db=dbengine.opendatabase(databasename)

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    well then try this
    VB Code:
    1. Dim DB as Database
    2. Dim RS as Recordset
    3. Dim SQLstatment as String
    4.  
    5. SQLstatment = "SELECT BLAH BLAH BLAH"
    6.  
    7. set DB=dbengine.opendatabase(databasename)
    8. Set RS = DB.OpenRecordset(SQLstatment)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    Originally posted by kleinma
    well then try this
    VB Code:
    1. Dim DB as Database
    2. Dim RS as Recordset
    3. Dim SQLstatment as String
    4.  
    5. SQLstatment = "SELECT BLAH BLAH BLAH"
    6.  
    7. set DB=dbengine.opendatabase(databasename)
    8. Set RS = DB.OpenRecordset(SQLstatment)
    yeah I have already written the code in my app. but my problem was in that sqlstatement. but now i'm seeing my answer in another thread right here.
    thanks

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