
mutou
Newbie
Jan 10, 2009, 10:07 PM
Post #1 of 1
(297 views)
Shortcut
|
|
VB6.0 connect encrypted Access database
|
Can't Post
|
|
This article from http://mutoucc.blogspot.com/2009/01/vb60-connect-encrypted-access-database.html Previously seen in the Visual Basic describes how to connect and use of Access database of technical articles, in fact, in the professional development of database software, in order to ensure the security of the database information often requested database file is encrypted to prevent illegal users other conventional means to open it. Then, in Visual Basic in how to create a database with the encrypted connection it? The author in the development of the university's dormitory management information system, summed up a number of methods and techniques, it is written exchanges with their peers. First, the establishment of a database Because in the Visual Basic 6.0 database connection in some way does not support the version of Access 2000 database format, in order to facilitate the problem, the paper's database to Access 97 version of the database as an example. In Microsoft Access 97 to create a database, such as: ssgl.mdb, and set the password, such as: "1234", and then database file and the VB project file created on the same directory. If the user's computer only Access 2000, you can start to build in the Access 2000 database ssgl.mdb and set a password, and then Access 2000 the "Database Utilities" into the database Access 97 version of the format. Of course, we can directly in the Visual Basic 6.0 integrated development environment through the "Visual Data Manager" to create a database in Access 97 and then set a password. Through the database file set a password, under normal circumstances, unauthorized users can not be used conventional means to open the database, the information in the database has played a certain role in the security and confidentiality. Second, connect the Access database encryption In Visual Basic 6.0, it is necessary to establish a connection with the database, to be used in many of the technical means, such as: data control, data objects, data such as environmental design. Developers can in accordance with its own conditions and needs of the users choose. Due to space limitations, only to introduce the following encrypted Access database with no encryption in the Access database connection difference. No encryption on the database and access method to connect readers can refer to other information. 1, the use of control ¢Ù Data Controls Data control is a Visual Basic 6.0, a built-in data control, you can set the Data control connect, DatabaseName, RecordSource attributes the achievement of the database connectivity and access. Data control to connect through an encrypted database There are two ways: One approach is in the design of state, in the "Properties window," Lieutenant General Data controls connect attribute default values "Access" changed "; pwd = 1234" can be, and other attributes set up methods and not encrypted Access database the same connection. Another method is to run through code assignment connect attributes to achieve. Such as: Data1.connect = "; pwd = 1234" Data1.DatabaseName = APP.path + "\ ssgl.mdb" Among them, the "1234" for the Access database file ssgl.mdb password, the same below. ¢Ú Adodc control ADODC control is an ActiveX control, which uses Microsoft ActiveX Data Objects (ADO) to create a connection to the database. ADODC controls the use of before the first controls will be added to the control ADODC toolbox. As follows: in the VB 6.0 options, "Project" menu, then click the "components" menu item in the pop-up "components" dialog box to select "Microsoft ADO Data Control 6.0 (OLEDB)" option. ADODC control connectivity through encrypted database, there are two methods: One approach is in the design of state, in the "Properties window" in control of ADODC ConnectionString property of an effective connection string, and after the increase in the connection string "; Jet OLEDB: DataBase password = 1234", again ADODC control settings CommandType, RecordSource attributes can create an encrypted database to connect. Another method is to run through the code to dynamically set the ConnectionString, CommandType and RecordSource property to create a connection. ConnectionString property as long as an effective link between the string after "; Jet OLEDB: DataBase password = 1234" can be. 2, the use of data objects ¢Ù DAO Data Objects To being able to correctly quoted DAO data object to create a connection with the database should be in the VB Integrated Development Environment, select the "Project" menu, then click the "reference" menu item in the pop-up "of" dialog box choose "Microsoft DAO 3.51 Object Library "option to add the DAO data object type library. Then you can use the following code to create Access database to an encrypted connection ssgl.mdb. Dim db AS DataBase Set db = OpenDataBase (App.path + "\ ssgl.mdb", False, False, "; pwd = 1234") ¢Ú ADO Data Objects ADO is Microsoft introduced to deal with relational database and non-relational database of information in the latest technology, Microsoft is also highly regarded for data connections and access to technology. In VB 6.0 in, Adodc controls, ADO data objects and DataEnvironment (Data Environment Designer) are using ADO technology, and thus they deal with encrypted Access database similar. To being able to correctly quoted ADO data objects should be in the VB 6.0 Integrated Development Environment, select "Project" menu, then click the "reference" menu item in the pop-up "of" dialog box, select "Microsoft ActiveX Data Objects 2.1 Library" election item to add ADO data object type library. Available the following code to create the Access database ssgl.mdb encrypted connection. Dim cnn AS ADODB.Connection Dim rst AS ADODB.Recordset Set cnn = New ADODB.Connection Cnn.Provider = "Microsoft.Jet.OLEDB.3.51" Cnn.ConnectionString = "Data Source =" & App.path & "\ ssgl.mdb;" & _ "; Jet OLEDB: Database password = 1234" cnn.Open ¢Û use DataEnvironment (Data Environment Designer) There are two ways to connect to the adoption of DataEnvironment encrypted Access database: One approach is in the design of state, in the DataEnvironment the connection object attributes ConnectionSource effective connection string to add "; Jet OLEDB: Database password = 1234 " Another method is in DataEnvironment_Initialize () event in the preparation of the following code: Private sub DataEnvironment_Initialize () Dim strconn AS string Strconn = "Provider = Microsoft.Jet.OLEDB.3.51;" & _ "Data Source =" & App.path & "\ ssgl.mdb;" & _ "; Jet OLEDB: Database password = 1234" DataEnvironment1.connection1.connectionstring = strconn End sub Methods and related code more than I have in the Windows 98 operating system environment, Visual Basic 6.0 in debug, verification and do pass.
|