Microsoft OLE DB Provider for ODBC Drivers Error '80040e21' A multi-step OLE DB operation produced an error. If possible, check each OLE DB status value. No work is done. A website program, an error occurred when adding news
The following is the error message:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
Multi-step OLE DB operation generates errors. If possible, check each OLE DB status value. No work is done.
The reason for this error is that I changed the access connection string to Driver={Micorsoft Access Driver ()};dbq= & Server.Mappath(DbPath), while the original connection string was Provier=Microsoft.Jet.OLEDB .4.0;Data source= & Server.Mappath(DbPath), this error will not occur. It seems that there are some differences between these two ways of connecting to the access database. At least the latter connection method is better in terms of fault tolerance, but it is obviously less formal in terms of specifications.
For the sake of simplicity, I will call these two methods provider connection and driver connection below.
The above error does not appear when modifying the news. I looked at the code and found that when adding, a record set obtained with Excute was not closed. I turned it off and couldn't get it to work correctly.
So I wrote a piece of code and designed a simple table. I found that two connection methods could be added at this time, so I changed the table in this code back to the original one, but it still couldn't be executed. Is it related to the watch?
So I started to study the form carefully and found that the original form had an automatic number field that was assigned a value in the program. I remember that automatic numbers cannot be assigned values. So I removed the automatic numbering of that table, and the result was that it could be executed normally.
It seems that it is possible to assign values to the automatic numbering field by connecting in Provider mode.
Let’s talk about the difference in another place.
When I used the driver to connect, a Null value appeared during channel setting, but it actually had a value in the database. I looked at the data type of this field and it was a comment. Does that mean that the driver's support for long notes is not very good? No, the news content in my news table must be notes. This should not be the reason.
What is the reason? Is it because he is behind another note? However, there are also two notes in the news table, and the content notes are also located behind the introduction notes. This suspicion was also eliminated.
Is it because this field has keywords? I changed the value of this field to 1, but the result was also wrong.
What's the reason?
Just write another page test yourself. The test code is as follows
The following is the test code:
Copy the code code as follows:
dim conn
set conn=server.createobject(adodb.recordset)
conn.open driver={Microsoft access driver (*.mdb)};dbq= & server.mappath(data/dd.mdb) 'driver connection method
'conn.open Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & server.mappath(data/dd.mdb) 'provider connection method
set rs=conn.execute(select * from s_channel where channelID=11)
response.Write rs(UploadSetting)
rs.close
setrs=nothing
If it is found that both connections can output normally.
So I output (response.write) in the original code where the record set was just opened, and found that the value of the field could be output normally at that location. So I kept moving the output code downwards, and finally moved it to
Here is the code snippet:
Copy the code code as follows:
if IsNull(rs(UploadSetting)) or rs(UploadSetting)= then
UploadSetting=Split(1,2,3,4@Other@2@0@jpg|gif|bmp|png@100@1@swf@500@1@rm|mp3|wav|mid|avi|mpg|mpeg| asf|wma@2048@1@rar|zip|exe|doc|xls|chm@2048@1,@)
else
UploadSetting=Split(rs(UploadSetting),@)
end if
When placed above if, the content can be output normally, but why is Null output when placed after else?
So the final test code is as follows
The following is the test code:
Copy the code code as follows:
dim conn
set conn=server.createobject(adodb.recordset)
conn.open driver={Microsoft access driver (*.mdb)};dbq= & server.mappath(data/dd.mdb) 'driver connection method
'conn.open Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & server.mappath(data/dd.mdb) 'provider connection method
set rs=conn.execute(select * from s_channel where channelID=11)
response.Write rs(UploadSetting)
if IsNull(Rs(UploadSetting)) or rs(UploadSetting)= then
response.Write dd
else
response.Write rs(UploadSetting)
end if
rs.close
setrs=nothing
The above code can correctly output the value in rs(uploadSetting) when connected in provider mode, but output nothing in Driver mode.
Can we understand this: in Driver mode, the remark content can only be referenced once, and it will become a NULL value when referenced again. This will not happen with Provider.
To adapt to this situation, we can only pass a variable. Let the content of the memo field be given to a variable first, rather than being quoted directly.