This article describes how to use ADO and ADOX to create and open a database in the framework of the MFC Document view. Read MFC technical Article TN025: Document, View, andFrameCreation Microsoft Knowledge Base Article Q183606ActiveXDataObjects (ADO) FrequentlyAskedQuestionsQ169496INFO: UsingActi
This article describes how to use ADO and ADOX to create and open a database in the MFC documentation/View/fram
Turn from: http://blog.junstudio.org/article.asp?id=262
I. Overview of ADOX
Microsoft?Activex? The data Objects Extensions for data Definition Language and Security (ADOX) is an extension of the ADO object and the programming model. ADOX includes objects for schema creation and modification, as well as security. Because it is an object-based implementation mode
CopyCode The Code is as follows: If trim (request. Form ("tablename "))
'---- Set to open the database connectionDBS = "Data Source =" + server. mappath ("database. mdb") + "; provider = Microsoft. Jet. oledb.4.0 ;"Set conn = server. Createobject ("ADODB. Connection ")Conn. Open DBS
'Define ADOX and specify the connectionSet ADOX = server. Createobject ("ADOX
A strange problem occurs during work. The "Unicode compression" attribute of a field is automatically set to false, which causes the nvarchar field value with a length of 50 to be automatically filled with spaces, to be a fixed-length field. Because the customer's data cannot be obtained, we can only find a way to solve the problem by programming. The process of solving the following records is full of hardships:
Through DDL. ADODB. Connection. Execute "alter table [tablename] add column [new
First, give a full version of the address. If you have installed the office on your machine, you should be able to open the: ADOX object model,
Address: "C: \ Program Files \ common files \ microsoft shared \ office11 \ 2052 \ ado210.chm ",
You can enter "hh.exe c: \ Program % 20files \ common % 20files \ microsoft % 20shared \ office11 \ 2052 \ ado210.chm:/htm/admscobjectmodel.htm" to locate the problem.
ADOX
First give a full version of the address, if you have a machine that Office should be able to open: ADOX object model,
The address is: "C:\Program files\common Files\Microsoft shared\office11\2052\ado210. CHM ",
You can enter in the run: "Hh.exe C:\Program%20Files\Common%20Files\Microsoft%20Shared\OFFICE11\2052\ADO210." Chm::/htm/admscobjectmodel.htm "positioning.
ADOX Object Model Diagram:
1,
After an ACCESS data file is created with ADOX, the *. ldb file appears until the program is closed. How can I disable the *. ldb file? (What are the disadvantages when it comes out? I didn't think about it. I just didn't want it to appear .) Interop. ADOX. dll should be a com component. Unlike. Net, the garbage collection mechanism has not been introduced in that era.
After an ACCESS data file is created w
Haha, no need to use ADOX !! % Dimcn, strCnn, rstSchemasetcnserver. createobject (ADODB. Connection) setstrCnnserver. createobject (ADODB. Recordset) setrstSchemaserver. createobject (ADODB. Recordset) strcnnprovidermicrof
Haha, no need to use ADOX !! % Dim cn, strCnn, rstSchema set cn = server. createobject ("ADODB. connection ") set strCnn = server. createobject ("ADODB. recordset ") set rstSchema = serve
Test environment: WINXP + VB6
Add two list boxes and one button
'Reference Microsoft ADO ext.2.x for DLL and security
Dim cat as ADOX. Catalog
Dim CNN as ADODB. Connection
Dim TBL as ADOX. Table
Private sub commandementclick ()
On Error resume next
For each TBL in cat. Tables
'If it is an sqlserver database, it becomes if left (TBL. Name, 3)
If left (TBL. Name, 4)
List1.additem TBL. Name
End if
Next
Ado| Index ADOX is said to be very powerful, but I did not feel it, because I wrote a lot of programs under ASP, can not run. For some reason, here's a program that can get a unique index. Maybe some friends will do some general-purpose programs, that is, no matter how the data structure changes, the program is unchanged, from data entry, modify, delete, to data retrieval. All modules are completely independent of the structure of the database table.
'*********************************
' * CLASSNAME:ADOXDBOPR
' * Producer: Liu Xiaoyi
' * Role: Using ADOX for database operations
' * Version: 1.0
' *www.jb51.net cloud-dwelling community
'**********************************
Class ADOXDBOPR
Dim objadox
Private Sub Class_Initialize
Set objadox=server.createobject ("ADOX. Catalog ")
End Sub
Public Property Let Connection (objconn)
Objadox.activeconnection=ob
General operation Access database, there are alter statements, and MSSQL2K basic syntax difference is not too dozen, for example, in a table to create a new column statement:
Dim sqlstr sqlstr="alter table l_info add column info_file varchar(200)default NULL" conn.execute(sqlstr)
The above statement creates column Info_file in L_info, for text type, length is 200, if there are no other settings, this time, the default:
Required field: No
Allow null character Fu Yi: No
This empty string can
'*********************************'* Classname: adoxdbopr'* Producer: Liu Xiaoyi'* Role: perform database operations using ADOX'* Version: 1.0'**********************************Class adoxdbopr
Dim objadox
Private sub class_initializeSet objadox = server. Createobject ("ADOX. catalog ")End sub
Public property let connection (objconn)Objadox. activeconnection = objconnEnd Property
Public Function arrtnameDim
judging whether it is unique. It turns out that this method is really good. Only the final program returns a string of N (n>=1) fields separated by commas (,). Most unique indexes, however, are made up of one field. We can also judge the types of these fields as needed. Fangins This is not the only way to get a unique index. Open a pattern query through the OpenSchema method of the data connection, or you can get a table of the main keyword, detailed method see [? here?].
ConnStr = "provider=ms
Because
Program ADOX is used, so you must first reference it in the solution. The method is as follows:
Solution Explorer --> reference --> (right-click) Add reference --> com --> Microsoft ADO Ext. 2.8 for DDL and security
1. ADOX Overview:Microsoft reg; ActiveX reg; Data Objects extensions for Data Definition Language and Security (ADOX) is an extension
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.