|
-
Sep 20th, 2002, 06:40 AM
#1
Thread Starter
Addicted Member
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?
-
Sep 20th, 2002, 06:44 AM
#2
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
-
Sep 20th, 2002, 06:53 AM
#3
Thread Starter
Addicted Member
Re: Re: SQL query
No I'm using DAO and i have opend the db before, useing:
set db=dbengine.opendatabase(databasename)
-
Sep 20th, 2002, 07:28 AM
#4
well then try this
VB Code:
Dim DB as Database
Dim RS as Recordset
Dim SQLstatment as String
SQLstatment = "SELECT BLAH BLAH BLAH"
set DB=dbengine.opendatabase(databasename)
Set RS = DB.OpenRecordset(SQLstatment)
-
Sep 20th, 2002, 07:36 AM
#5
Thread Starter
Addicted Member
Originally posted by kleinma
well then try this
VB Code:
Dim DB as Database
Dim RS as Recordset
Dim SQLstatment as String
SQLstatment = "SELECT BLAH BLAH BLAH"
set DB=dbengine.opendatabase(databasename)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|