国产毛片午夜福利,国产黄网,国产亚洲天堂,97国产精品

  •  
    ASP動(dòng)態(tài)網(wǎng)頁技術(shù)的數(shù)據(jù)庫語法總結(jié)
    發(fā)布時(shí)間:2008-07-03   瀏覽次數(shù):1181488
    ASP動(dòng)態(tài)網(wǎng)頁技術(shù)的數(shù)據(jù)庫語法總結(jié) 經(jīng)常使用到有關(guān)數(shù)據(jù)庫的操作。 包括連接代碼、SQL命令等等,又不曾刻意去記憶它們(我本人是不愿意去記這東東),所以常常在用到的時(shí)候又去查書本,翻來翻去。一些比較少用的數(shù)據(jù)庫還不一定能順利找到,所以現(xiàn)在把它們?nèi)珰w納到這里,提供大家參考。(個(gè)人水平有限,有缺陷之處,歡迎大家指正。) ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 專業(yè)的WEB編程資訊技術(shù)站點(diǎn),歡迎訪問!<一>數(shù)據(jù)庫的連接方法:1.Access數(shù)據(jù)庫的DSN-less連接方法:setadocon=Server.Createobject("adodb.connection")adoconn.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&_Server.MapPath("數(shù)據(jù)庫所在路徑") 此內(nèi)容來源于 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)頁編程資訊官方網(wǎng)站!2.AccessOLEDB連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"rovider=Microsoft.Jet.OLEDB.4.0;"&_"DataSource="&Server.MapPath("數(shù)據(jù)庫所在路徑") 此內(nèi)容來源于 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)頁編程資訊官方網(wǎng)站!3.SQLserver連接方法:setadocon=server.createobject("adodb.recordset")adocon.Open"Driver={SQLServer};Server=(Local);UID=***WD=***;"&_"database=數(shù)據(jù)庫名;" ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 全力打造WEB技術(shù)站點(diǎn),歡迎大家訪問!4.SQLserverOLEDB連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"provider=SQLOLEDB.1;DataSource=RITANT4;"&_"userID=***assword=***;"&_"initalCatalog=數(shù)據(jù)庫名" ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 專業(yè)的WEB編程資訊技術(shù)站點(diǎn),歡迎訪問!5.Oracle連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"Driver={microsoftodbcfor oracle};server=oraclesever.world;uid=admin;pwd=pass;" 本文由 點(diǎn)擊設(shè)計(jì) http://www.djasp.Net 收集整理。謝絕無聊之人轉(zhuǎn)載!6.OracleOLEDB連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"rovider=OraOLEDB.Oracle;datasource=dbname;user id=admin;password=pass;" 請勿盜版 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)站上的內(nèi)容,謝謝合作!7.dBase連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"Driver={microsoftdbasedriver(*.dbf)};driverid=277;dbq=------------;"8.mySQL連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"Driver={mysql};database=yourdatabase;uid=username;pwd=yourpassword;option=16386;" 此內(nèi)容來源于 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)頁編程資訊官方網(wǎng)站!9.VisualFoxpro連接方法:setadocon=Server.Createobject("adodb.connection")adocon.open"Driver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;"請勿盜版 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)站上的內(nèi)容,謝謝合作!10.MS text 連接方法:set adocon=Server.Createobject("adodb.connection")adocon.open"Driver={microsoft text driver(*.txt; *.csv)};dbq=-----;"&_"extensions=asc,csv,tab,txtersist SecurityInfo=false;"本文由 點(diǎn)擊設(shè)計(jì) http://www.djasp.Net 收集整理。謝絕無聊之人轉(zhuǎn)載!11.MS text OLE DB 連接方法:set adocon=Server.Createobject("adodb.connection")adocon.open"Provider=microsof.jet.oledb.4.0;data source=your_path;"&_"Extended Properties'text;FMT=Delimited'"<二>常用的四種SQL命令:請勿盜版 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)站上的內(nèi)容,謝謝合作!1.查詢數(shù)據(jù)記錄(Select)語法:Select 字段串行 From table Where 字段=內(nèi)容例子:想從book表中找出作者為"cancer"的所有記錄,SQL語句便如下:select * from book where author=’cancer’"*"是取出book表所有的字段,如查詢的字段值為數(shù)字,則其后的"內(nèi)容"便無須加上單引號,如是日期,則在Access中用(#)包括,而在SQL server中則用(’)包括,如:select * from book where id=1select * from book where pub_date=#02-1-7# (Access)select * from book where pub_date=’02-1-7’ (SQL Server)提示:日期函數(shù)to_date不是標(biāo)準(zhǔn)sql文,不是所有的數(shù)據(jù)庫適用,所以大家在使用的時(shí)候要參考數(shù)據(jù)庫具體語法另外如果是查詢傳入的變量,則如下:strau=request.form("author")strsql="select * from book where author=’"&strau&"’"如果查詢的是數(shù)字,則:intID=request.form("id")strsql="select * from book where id="&intID在很多數(shù)據(jù)庫中,如:oracle,上面的語句是可以寫成:strsql="select * from book where id='"&intID&"'"的。 但是字符型一定不能按照數(shù)字格式寫,需要注意。請勿盜版 ★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 網(wǎng)站上的內(nèi)容,謝謝合作!2.添加記錄(Insert)語法:Insert into table(field1,field2,....) Values (value1,value2,....)例子:添加一作者是"cancer"的記錄入book表:insert into book (bookno,author,bookname) values (’CF001’,’cancer’,’Cancer無組件上傳程序’)同樣,如果用到變量如下:strno=request.form("bookno")strau=request.form("author")strname=request.form("bookname")strsql="insert into book (bookno,author,bookname) values (’"&strno&"’,’"&strau&"’,’"&strname&"’)"3.用Recordset對象的Addnew插入數(shù)據(jù)的方法:語法:rs.addnewrs("field1").value=value1rs("field2").value=value2...rs.update盜版它人網(wǎng)站的內(nèi)容可恥,您查看的內(nèi)容來源于★點(diǎn)擊設(shè)計(jì)★www.djasp.Net 4.修改數(shù)據(jù)記錄(Update)語法:update table set field1=value1,field2=value2,...where fieldx=valuex例子:update book set author=’babycrazy’ where bookno=’CF001’如果用到變量如下:strno=request.form("bookno")strau=request.form("author")strsql="update book set author=’"&strau&"’ where bookno=’"&strno"’"★點(diǎn)擊設(shè)計(jì)★ http://www.djasp.Net 全力打造WEB技術(shù)站點(diǎn),歡迎大家訪問!5.Recordset對象的Update方法:語法:rs("field1").value=value1rs("field2").value=value2...rs.update注意:使用語法3和語法5的時(shí)候,一定要注意字段的類型(尤其是日期型)一致,否則出錯(cuò)的幾率非常的高。 例子:strno=request.form("bookno")strau=request.form("author")setadocon=server.createobject("adodb.connection")adocon.open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&_Server.Mappath=("/cancer/cancer.mdb")strsql="select*frombookwherebookno=’"&strno&"’"setrs=server.createobject("adodb.recordset")rs.openstrsql,adconn,1,3ifnotrs.eofthen’如果有此記錄的話rs("author").value=straurs.updateendifrs.closesetrs=nothingadocon.closesetadocon=nothing 本文由 點(diǎn)擊設(shè)計(jì) http://www.djasp.Net 收集整理。謝絕無聊之人轉(zhuǎn)載!6.刪除一條記錄(Delete)語法:Deletetablewherefield=value例子:刪除book表中作者是cancer的記錄deletebookwhereauthor=’cancer’(注意:如果book表中author字段的值為cancer的記錄有多條,將會(huì)刪除所有author為cancer的記錄)好了,學(xué)會(huì)了用這些操作,大家在用asp操作數(shù)據(jù)庫的時(shí)候,該是沒有什么問題了。
    立即預(yù)約