ASP perfectly converts access to SQL database connection

Source: Internet
Author: User

In fact, the basic general steps are as follows:
1. Convert MDB databases to SQL tools.
2. Change the database link string to the following code:
Set conn = server. Createobject ("ADODB. Connection ")
SQL = "driver = {SQL Server}; server = XD-Y1W9B7; uid = sa; Pwd = sa; database = ljl"
Conn. Open (SQL)

Finally, what is the difference between SQL and access? please note the following:

Convert access to SQL database

Many of my friends want to use the SQL2000 database programming method, but they suffer from learning Access, just a little understanding of SQL, here I will provide you with the following reference-methods and precautions for converting access into SQL2000

I. First of all, I am talking about the conversion between Access2000 and SQL2000. I have not tried any other products yet. I hope you can experiment more and find a solution;

Ii. Conversion Method
1. Open "database source" in "Management Tools" under "Control Panel";
2. Press "add" to add a new data source, and select "Driver do Microsoft Access (*. MDB) ", a box will appear, enter the name you want to write in" database source ", I name it" ABC ", it means no need to fill in, then, find your database address and select the address (Note: Back up your own access database first), and then confirm. The data source is created here, and the conversion is left.
3. Open SQL2000 Enterprise Manager, enter the database, and create an empty Database "ABC ";
4. Select the new database, right-click the database, select "import data" under "all tasks", and click "Next;
5. Select "Driver do Microsoft Access (*. MDB) ", in" User/system DSN ", select the" ABC "you just added and press" Next ";
6. The "destination" does not need to be modified. You can select a server (generally "local" for your local machine) or a server address or LAN address, determine whether your permissions can be operated.) "using Windows Identity Authentication" means using your system administrator identity. "using SQL Identity Authentication" can be used for website operations, the latter is recommended;
7. After selecting "use SQL authentication", enter your username and password. I chose the default system number "sa", "***", select the newly created "ABC" for the database and press "Next".
8. Select "Copy table and view from data source" and "use a query command to specify the data to be transmitted", select the former, and press "Next" to continue;
9. here you will see your own access database table. After you press "select all", next step;
10. In the "DTS import/export wizard", see "Run now" and press "Next",
11. Press "finish" to continue;
12. In this step, you will see that your data has been imported into SQL2000. When "XXX tables have been successfully imported into the database" appears, in addition, if there is a green check in front of all tables, it means that all data is successfully imported. If there is a problem in the middle or there is a red cross in front of the table, it means that the table has not been imported successfully, in this case, you have to go back and check whether your operations are correct.

3. data modification
1. Because SQL2000 does not contain "automatic number", all fields you set with "automatic number" will become non-empty fields, which must be manually modified, and select "yes" for his "mark", the seed is "1", and the increment is "1",
2. In addition, after Access2000 is converted to SQL2000, the field with the original attribute "yes/no" will be converted to a non-empty "bit", at this time, you must modify it to the desired attribute;
3. In addition, you should pay attention to the grasp of time functions. Access and SQL are many different. What should you pay attention to when changing access to SQL?
After the database is imported, fields that need to be automatically added must be overwritten, and the length of all numeric types must be increased. It is best to use decimal.
All default values are lost. It mainly belongs to the numeric type and date type.
All now (), time (), date () must be changed to getdate ().
Change all datediff ('D', time1, time2) to datediff (day, time1, time2)
Some types of true/false may not be available and must be changed to 1/0.
The remarks type must be cast (column as varchar.
The value of cursortype must be changed to 1, that is, when the database is opened, the first numeric parameter must be set to 1. Otherwise, the record may be incomplete.
Change isnull (rowname) to rowname = NULL
When the automatic numbering type in the ACCESS database is converted, SQL server does not set it to the automatic numbering type. We need to add the identity in the SQL creation statement to indicate the automatic numbering!
During conversion, SQL Server defaults to the smalldatetime type for date-related fields. We recommend that you change it to the datetime type because the datetime type has a larger range than the smalldatetime type. Sometimes, if the smalldatetime type is used, the conversion fails. If the datetime type is used, the conversion is successful.
The SQL statements used to operate these two databases are not all the same. For example, when you delete a record in an Access database, use the following statement: "delete * from user where id = 10". to delete an SQL Server database, run the following command: "delete user where id = 10".
Date functions are different. functions such as date () and time () can be used in Access database processing. However, functions such as datediff and dateadd can only be used in SQL Server database processing, instead, functions such as date () and time () cannot be used.
In the process of Access database, some VB functions can be used in SQL statements, such as the CSTR () function, but cannot be used in the process of SQL Server database.

Experience in converting access to SQL Server databases

1. When the automatic numbering type in the ACCESS database is converted, SQL server does not set it to the automatic numbering type. We need to add the identity in the SQL creation statement to indicate the automatic numbering!
2. During conversion, SQL Server defaults to the smalldatetime type for date-related fields. We recommend that you change it to the datetime type because the datetime type has a larger range than the smalldatetime type. In this case, if the smalldatetime type is used, the conversion fails. If the datetime type is used, the conversion is successful.
3. the SQL statements used to operate these two databases are not all the same. For example, when you delete a record in an Access database, use the following statement: "delete * from user where id = 10". to delete an SQL Server database, run the following command: "delete user where id = 10".
4. date functions are different. functions such as date () and time () can be used in Access database processing. However, functions such as datediff and dateadd can only be used in SQL Server database processing, instead, functions such as date () and time () cannot be used.
5. For Access database processing, some VB functions can be used in SQL statements, such as CSTR () functions, but not in SQL Server database processing.

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.