<%
OpenConn()翻开数据库毗连
Dimdb:Setdb=NewDbCtrl创建工具
YourCodeHere......
Co(db):CloseConn()开释工具,封闭数据库毗连
%>
<%
Dimdb1:Setdb1=NewDbCtrl:db1.dbConn=Oc(a)
Dimdb2:Setdb2=NewDbCtrl:db2.dbConn=Oc(b)
YourCodeHere......
Co(db1):Co(db2)
%>
CreatConn天生数据库毗连字符串
Oc创建数据库毗连
Co开释工具
OpenConn翻开默许数据库毗连
CloseConn封闭默许数据库毗连
dbCtrl.dbConn属性,猎取要操纵的数据库毗连,默许值为Conn
dbCtrl.dbErr属性,只读,输入捕捉的毛病信息
dbCtrl.Version属性,只读,程序版本信息
dbCtrl.AutoId办法,主动猎取独一序列号
dbCtrl.GetRecord办法,获得切合前提的记录集
dbCtrl.GetRecordBySql办法,依据sql语句获得记录集
dbCtrl.GetRecordDetail办法,依据某一条指定记录的具体数据
dbCtrl.AddRecord办法,增加一个新的记录
dbCtrl.UpdateRecord办法,依据指定前提更新记录
dbCtrl.DeleteRecord办法,删除切合前提的记录
dbCtrl.ReadTable办法,依据指定前提猎取某条记录中的其他字段的内容
dbCtrl.C办法,封闭记录集工具
dbCtrl.wGetRecord,
dbCtrl.wAddRecord,
dbCtrl.wUpdateRecord,
dbCtrl.wDeleteRecord这4个办法是获得响应的操纵(后面加w)的sql语句
Array("Field1:Value1","Field2:True","Field3:100")
对,有点像json的格局,假如触及到变量,那就如许:
Array("Field1:"&Value1,"Field2:"&Value2,"Field3:"&Value3)
Dima:a=CreatConn(0,"TestData","localhost","username","userpassword")
Dimb:b=CreatConn(1,"Data/%TestDb%.mdb","","","")
Dimc:c=CreatConn("ACCESS","E:MyWebData\%TestDB%.mdb","","","mdbpassword")
Dimdb:Setdb=NewDbCtrl
db.dbConn=Oc(CreatConn(1,"E:WebSiteMySiteData\%TestDb%.mdb","","",""))
Co(db)
DimnewId
newId=db.AutoId("TestTable")
Response.Write(newId)
Dimrs
Setrs=db.GetRecord("TestTable","fId,fName,fAge","fSex=男AndIsActive=1","fNameAsc",0)
WhileNotrs.eof
Response.Write("Nameis:"&rs(1)&"Ageis:"&rs(2)&"<br/>")
rs.movenext()
Wend
db.C(rs)
Setrs=db.wGetRecord("TestTable","fId,fName,fAge",Array("fSex:男","IsActive:1"),"fNameAsc",0)
Response.Write(db.wGetRecord("TestTable","fId,fName,fAge",Array("fSex:男","IsActive:1"),"fNameAsc",0))
Dimrs
Setrs=db.GetRecordBySQL("Selecta.Id,a.LastName,b.GroupFromUseraInnerJoinDepartbOna.GroupId=b.GroupId")
YourCodeHere...
db.C(rs)
Dimrs,Id
Id=Request.QueryString("id")
Setrs=db.GetRecordDetail("TestTable","Id="&id)
YourCodehere...
db.C(rs)
DimfName,fSex,fWorkYear,fBirth
fName="王二坛"
fSex="男"
fWorkYear=12
fBirth=Cdate("1981-10-23")
Dimresult
result=db.AddRecord("TestTable",Array("Name:"&fName,"Sex:"&fSex,"WorkYear:"&fWorkYear,"Birthday:"&fBirth,"IsActive:True"))
Ifresult0Then
Response.Write("增加纪录乐成!此纪录的主动编号Id为"&result)
EndIf
result=db.AddRecord("TestTable",Array("Name:"&fName,_
"Sex:"&fSex,_
"WorkYear:"&fWorkYear,_
"Birthday:"&fBirth,_
"IsActive:True"))
Response.Write(db.wAddRecord("TestTable",Array("Name:"&fName,"Sex:"&fSex,"WorkYear:"&fWorkYear,"Birthday:"&fBirth,"IsActive:True")))
DimfName,fWorkYear
fName="王三坛"
fWorkYear=10
Dimresult
result=db.UpdateRecord("TestTable","UId=1308",Array("Name:"&fName,"WorkYear:"&fWorkYear))
Ifresult0Then
Response.Write("更新数据乐成!")
EndIf
Response.Write(db.wUpdateRecord("TestTable","UId=1308",Array("Name:"&fName,"WorkYear:"&fWorkYear)))
Dimids,result
ids=Request.Form("selectid")能够假定这里猎取的值是12,34,256,314(复选框提交的值都如许)
result=db.DeleteRecord("TestTable","UId",ids)
Ifresult0Then
Response.Write("删除数据乐成!")
EndIf
result=db.DeleteRecord("TestTable","UId","IsActive=0AndFirstName=Tom")
Response.Write(db.wDeleteRecord("TestTable","UId",ids))
Dimuid,result
uid=rs("postid")假定这里是页面上某个纪录会合的用户id值
result=db.ReadTable("UserTable","UId="&uid,"UserName")
Response.Write("公布者:"&result)
Dimuid,result
uid=rs("postid")假定这里是页面上某个纪录会合的用户id值
result=db.ReadTable("UserTable","UId="&uid,"UserName,UserSex,UserAge")
Response.Write("公布者:"&result(0)&"<br/>性别:"&result(1)&"<br/>岁数:"&result(2))
Dimrs
Setrs=db.GetRecordDetail("TestTable","Id=123")
YourCodehere...
db.C(rs)
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |