Home > Software engineering >  [for] SQL statement appears at least one parameter is not specified value error
[for] SQL statement appears at least one parameter is not specified value error

Time:09-17

Purpose is through the ACCESS of data in a library to find the temperature of 340 physical parameters and output to the work table
Sub for physical parameters ()
Dim CNN As New Connection, RST As you, FLD As Field
Dim strSq1 As String, I, As Long As strConn String
StrSq1="SELECT * FROM [CO278] WHERE [Temperature]='340'"
StrConn="Provider=Microsoft. ACE. The OLEDB. 12.0. Data Source=C: \ Users \ DELL \ Documents \ CO2 MDB
"CNN. The ConnectionString=strConn
CNN. Open
The Set RST=CNN. The Execute (strSq1)
With Worksheets (" sheet1 ")
I=1
For Each FLD In RST. Fields
Cells (1, I)=FLD. Name
Next
J=1
EOF
the Do While Not RST.I=1
J=j + 1
For Each FLD In RST. Fields
Cells (j, I)=FLD. Value
I=I + 1
Next
RST. MoveNext
Loop
End With
RST. Close
CNN. Close
The Set of RST=Nothing
The Set of CNN=Nothing
End Sub
I don't know the problem there

CodePudding user response:

Are you on both sides of the asterisk lack of space?

CodePudding user response:

Positive solution upstairs!!!!!

CodePudding user response:

refer to the second floor chewinggum response:
upstairs truth!!

Well, that seems I was the right time,

CodePudding user response:

Not, add a space after the mistakes

CodePudding user response:

Table [CO278] no field [Temperature]

CodePudding user response:

The Set of RST=CNN. The Execute (strSq1) instead of RST. Open strSq1, CNN a try,

CodePudding user response:

StrSq1="SELECT * FROM [CO278] WHERE [Temperature]='340'"
Temperature field is a string type?

CodePudding user response:

Dim CNN As New Connection, RST As you, FLD As Field
Dim strSq1 As String, I, As Long As strConn String
StrSq1="SELECT * FROM [CO278] WHERE [Temperature]=340"
StrConn="Provider=Microsoft. ACE. The OLEDB. 12.0. Data Source=C: \ Users \ DELL \ Documents \ CO2 MDB
"CNN. The ConnectionString=strConn
CNN. Open



STRSQL="select * from [jishijilu]" 'where gyh_riqi=' "& amp; "1000-061210" & amp; "' group by gyh_riqi
"CNN. The ConnectionString="Provider=Microsoft. Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ wd. MDB; Persist Security Info=False "
CNN. Open
Rs. CursorLocation=adUseClient
Rs. The Open STRSQL, CNN, adOpenDynamic adLockOptimistic

please refer to the supplied code test

CodePudding user response:

1, whether the field name spelled correctly
2, whether the field type string (not the '340' to get rid of single quotes)

CodePudding user response:

Before I met a problem, agreed to check the database field name is "Temperature", have the letters inconsistencies

CodePudding user response:

You can put the paste the SQL statements directly to your database, if you can run normally, shows the SQL statement that's right, if prompt parameter is missing, no doubt, it must be misspelled
  •  Tags:  
  • VBA
  • Related