Differences between ASP driver and provider in connecting strings to access

Source: Internet
Author: User

One website Program , An error occurred while adding news
The following are error messages:
Microsoft ole db provider for ODBC drivers error '80040e21'
Multiple ole db operations generate errors. If possible, check the status value of each ole db. No work is completed.
This error occurs because I changed the access connection string to "driver = {micorsoft access Driver ()}; DBQ =" & server. mappath (dbpath), and the original connection string is "provier = Microsoft. jet. oledb.4.0; Data Source = "& server. this error does not occur when mappath (dbpath) is used. It seems that there are some differences between the two access database methods. At least the latter connection method has better fault tolerance, but it is obviously not formal in terms of specifications.
In order to make the description simple, the two methods are called provider connection and driver connection respectively.
These errors do not occur when you modify the news. I looked at it. Code It is found that a record set obtained with excute is not closed during the execution of the add operation. I disabled it and cannot execute it correctly.
So I wrote a piece of code and designed a simple table. I found that the two connection methods can be added, so I changed the tables in the code back to the original one, it cannot be executed. Is it related to tables?
So I began to study the table carefully and found that the original table had an automatic number field assigned a value in the program. I remember that automatic numbers cannot be assigned values. So I automatically numbered the table and the result can be executed normally.
It seems that the provider method can be used to assign values to the automatically numbered field.
Next we will talk about the differences between the two parts.
When I use driver to connect, a null value is displayed during channel settings, but in fact there is a value in the database. I have read the data type of this field, which is a note. That is not to say that the driver does not support long remarks? No. The news content in my news table must be noted. It should not be the reason.
Why? Is it because he is behind another remark? However, there are also two remarks in the News table, and the content remarks are also behind the description remarks. This suspicion is also ruled out.
Is this field a keyword? I changed the field value to 1, and the result is also an error.
What is the reason?
Simply write another page for testing. The test code is as follows:
The following is the test code: Copy code The Code is 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 rs1_conn.exe cute ("select * From s_channel where channelid = 11 ")
Response. Write RS ("uploadsetting ")
Rs. Close
Set rs = nothing

If two connections are found to be normal.
I output (response. Write) at the place where the record set was just opened in the original code, and found that the value of this field can be normally output at that location. So I kept the output code moving down, and finally moved to
The following is the code snippet: copy Code the code is 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

Put it on the if interface can normally output the content, but put it behind else to output null. Why?
The final test code is as follows:
The following is the test code:Copy codeThe Code is 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 rs1_conn.exe cute ("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
Set rs = nothing

The above code correctly outputs the value in RS ("uploadsetting") when using the provider Method for connection, but does not output anything in the driver mode.

Can we understand this as follows: In the driver mode, only one reference to the remarks can be made, and the value is null when the remarks are referenced again. Provider does not.

to adapt to this situation, we can only use one variable. Let the content of the remarks field first give a variable instead of directly referencing it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.