ASP connection database ASP link Database string Encyclopedia summary 1th/2 page _asp Basics

Source: Internet
Author: User
Tags dbase ole access database
Operations on the database are often used. Including the connection code, SQL commands and so on, and never deliberately to remember them (I am not willing to remember this stuff), so often in the use of the time to check the books, turn over. Some relatively less use of the database may not be able to find a smooth, so now they are all summed up here, to provide you with reference. (Personal level is limited, there are defects, you are welcome to correct the point.) )

< a >. How the database is connected:

1.Access Database Dsn-less Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adoconn. Open driver={microsoft Access Driver (*.mdb)};D bq= "& _
Server.MapPath ("Path to Database")

2.Access OLE db connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data source=" & Server.MapPath ("Path to Database")

3.SQL Server Connection method:

Set Adocon=server.createobject ("Adodb.recordset")
ADOcon. Open "Driver={sql Server}; server= (local); uid=***; pwd=***; " & _
"Database= database name;"

4.SQL Server OLE db connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Provider=SQLOLEDB.1;Data source=ritant4;" & _
"User id=***; password=***; " & _
"Inital catalog= database name"

5.Oracle Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Driver={microsoft ODBC for Oracle};server=oraclesever.world;uid=admin;pwd=pass;"

6.Oracle OLE DB Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Provider=oraoledb.oracle;data source=dbname;user id=admin;password=pass;"

7.dBase Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Driver={microsoft dbase Driver (*.dbf)};d riverid=277;dbq=------------;"

8.mySQL Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Driver={mysql};d atabase=yourdatabase;uid=username;pwd=yourpassword;option=16386;"

9.Visual Foxpro Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Driver={microsoft Visual Foxpro driver};sourcetype=dbc;sourcedb=*.dbc; Exclusive=no; "

10.MS Text Connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Driver={microsoft text Driver (*.txt; *.csv)};d bq=-----;" &_
"Extensions=asc,csv,tab,txt; Persist Securityinfo=false; "

11.MS text OLE DB connection method:

Set Adocon=server.createobject ("Adodb.connection")
Adocon.open "Provider=microsof.jet.oledb.4.0;data Source=your_path;" &_
"Extended Properties" text; Fmt=delimited ' "

< two >. The four commonly used SQL commands:

1. Query data records (SELECT)
Syntax: Select field serial from table Where field = Content
Example: To find all the records of the author as "Cancer" from the Book table, the SQL statement reads as follows:
SELECT * FROM book where author= ' cancer '
"*" is to remove all the fields in the Book table, such as the query's field value is a number, then the "content" will not need to add single quotes,

As a date, included in Access (#), and included in SQL Server ('),
Such as:

SELECT * FROM book where id=1
SELECT * FROM book where pub_date= #2002 -1-7# (Access)
SELECT * FROM book where pub_date= ' 2002-1-7 ' (SQL Server)

Tips:
Date function to_date is not standard SQL, not all databases are applicable, so you should refer to the database syntax when using
Current 1/2 page 12 Next read the full text
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.