Differences between ASP driver and provider two connection strings when connecting to access _ database related

Source: Internet
Author: User
Tags access database
A Web site program that has an error when adding news
The following are the error tips:
Microsoft OLE DB Provider for ODBC Drivers error ' 80040e21 '
Multi-step OLE DB operation generated an error. If possible, check each OLE DB status value. No work is done.
This error occurs because I modified the access connection string to "Driver={micorsoft Access Driver ()};d bq=" & Server.MapPath (DBPath), and the original connection string was " This error does not occur when Provier=microsoft.jet.oledb.4.0;data source= "& Server.MapPath (DBPath). There seems to be some difference between the two ways to connect to an Access database. At least the latter type of connection is better at fault tolerance, but it is obviously less formal in specification.
To describe it simply, I'm going to call these two ways provider and driver connections, respectively.
These errors do not appear when you modify the news. I looked at it. The code found that when the addition was performed, a recordset obtained with Excute was not closed. I shut it down and I can't execute it properly.
So I wrote a piece of code, and also designed a simple table, and found that the two connection methods can be added, so I will be the table in this code back to the original, or not to execute. Does it have something to do with the table?
So I began to study the form carefully and found that there was an AutoNumber field in the original table that was assigned in the program. I remember the automatic numbering is not to be assigned to the AH. So I went to the automatic number of the table, the result can be performed normally.
It seems that a provider connection is a way to assign a value to an AutoNumber field.
Let's talk about the difference in another place.
When I use the driver connection, a null value appears in the channel settings, but in fact there is a value in the database, I looked at the data type of the field, is the note. Does that mean that the driver driver is not too good at supporting long notes? No, the news in my news form must be a remark, it should not be the reason.
What is the reason? Is it because he is in the back of another remark? However, there are two comments in the news table and the content notes are located behind the introductory remarks. This suspicion was also ruled out.
Is it because this field is the reason for the keyword? I change this field value to 1, and the result is an error.
What is the reason for that?
Simply write a page test yourself and test the code as follows
Here is the test code:
Copy Code code as follows:

Dim conn
Set Conn=server.createobject ("Adodb.recordset")
Conn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" & 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 mode
Set Rs=conn.execute ("SELECT * from S_channel where channelid=11")
Response. Write rs ("uploadsetting")
Rs.close
Set RS =nothing

If two connections are found to be normal output.
So I output (Response.Write) in the original code where the recordset was just opened, and found that the value of the field could be output normally in that location. So I'm going to keep moving the output code down, and eventually move to
The following is a code fragment:
Copy 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

The output is normal on the IF, but what is the reason for the output null after the else?
So the final test code is as follows
Here is the test code:
Copy Code code as follows:

Dim conn
Set Conn=server.createobject ("Adodb.recordset")
Conn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" & 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 mode
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
Set RS =nothing

The code above, when connected using the provider method, can correctly output the value in RS ("uploadsetting"), and nothing is output in the driver mode.

Is it possible for us to understand that, in the driver mode, a reference to the contents of a memo can only be referenced once, and then it becomes a null value when it is referenced again. This is not the case with provider.

For this adaptation, we can only pass a variable. Let the contents of the Memo field first be given a variable, not a direct reference.
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.