Home > Software engineering >  Vb access database query format
Vb access database query format

Time:09-17

Note operation date for the column name format for the date

Dim sqla sa string
Sqla="Select * From table name Where the operation date BETWEEN #" & amp; DTPicker1 & amp; "# AND #" & amp; DTPicker2 & amp; "#", "

Adodc1. The connectionstring=",,,,,, "
Adodc1. RecordSource=sqla
Adodc1. Refresh


Run after the prompt date date of grammatical errors in the query expression 'operation between # # # and # 2018/5/2 2018/5/1 Friday Saturday'

Excuse me why complains!
Which step is wrong, please advise

CodePudding user response:

Here to arrange at least one parameter is not specified value error may cause:
Reasons: 1, the SQL statement because access database support for join syntax has limitations, so in writing the access database join statements reference this article introduces the SQL format: access database table more joint query (Left join, etc.) of SQL statements written, in fact, sometimes also can consider the multi-table query: select * from table1 and table2 where table1. The tid=table2. Dar and table1. The userid='A00001',
2, the field name to write wrong, although this error is very low, but it often happens, so when the access database hint at least one error parameters were not specified value, advice in SQL comparing to the patient whether each field name and the field name in the data table is consistent,
Pay attention to the problem above, no longer afraid of access database has not been specified parameters of the at least one mistake,
Thanks to the master, in the hope that useful to friends,
Refer to the link https://zhidao.baidu.com/question/1796076501101539987.html? Fr=iks& Word=vb + select D9 C9 C1 D6 + % % % % % % % BB D2 B8 FD CA CE B2 F6 % % % % % % % C3 BB BB B1 D0 D3 % % % % % D6 D6 A8 B6 B8 % % % % % B5 & amp; GBK ie=

CodePudding user response:

Sqla="Select * From table name Where the operation date BETWEEN # "" & amp; DTPicker1 & amp; " " AND "" & amp; DTPicker2 & amp; ""
If DTPicker1 and DTPicker2 controls of the VB interface, format should be!

CodePudding user response:

Try:

Sqla="Select * From table name Where the operation date BETWEEN #" & amp; Format (DTPicker1, YYYY - mm - "dd") & amp; "# AND #" & amp; Format (DTPicker2, YYYY - mm - "dd") & amp; "#", "

May be related to the database engine's ability to parse time date string is related to some format can't handle it,

The wrong on the second floor, the time of Access database date string enclosed in # #, SQL library time date to use quotation marks, and cannot use both at the same time,

CodePudding user response:

Error so clear tell you
date of grammatical errors in the query expression 'operation date between # # # and # 2018/5/2 2018/5/1 Friday Saturday'
You haven't seen date expression is wrong? That Friday do you understand, look not to understand

CodePudding user response:

This don't add on Friday, the 2008-1-1 8:33:22 here can take part

CodePudding user response:

SQL statement is, in fact completely as a string,

Date/time format data is actually a Double number, when to date/time string, there are a variety of formats, use which format depends on the control panel in the "date, time, language and regional Settings",

And can get what you need to Format Format string Format,

CodePudding user response:

The & amp; Try to +

CodePudding user response:

Change date variable growth date format try: yyyy - mm - dd

CodePudding user response:

Change
Qla="Select * From table name Where the operation date BETWEEN #" & amp; Format (DTPicker1, yyyy - mm - "dd") & amp; "# AND #" & amp; Format (DTPicker2, yyyy - mm - "dd") & amp; "#", "
Have a try
  • Related