|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
asp对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。数据|数据库<%Definingsomeconstantstomakemylifeeasier!(SameasSample1&2)
BeginConstantDefinition
DBConfigurationconstants
FakeconstsowecanusetheMapPathtomakeitrelative.
Afterthis,strictlyusedasifitwereaConst.
DimDB_CONNECTIONSTRING
DB_CONNECTIONSTRING="DRIVER={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.Mappath
("./db_scratch.mdb")&";"
Wedontusethese,butwecouldifweneeededto.
ConstDB_USERNAME="username"
ConstDB_PASSWORD="password"
NowweoverridetheabovesettingstouseourSQLserver.
DeletethefollowinglinetousethesampleAccessDB.
DB_CONNECTIONSTRING=Application("SQLConnString")&"UID="&Application("SQLUsername")
&";PWD="&Application("SQLPassword")&";"
ADODBConstants
Youcanfindtheseintheadovbs.incfile
Doasearchforitanditshouldturnupsomewhereontheserver
Ifyoucantfindityoucandownloadourcopyfromhere:
http://www.asp101.com/samples/download/adovbs.inc
Itmaynotbethemostrecentcopysouseitatyourownrisk.
%>
<!--#INCLUDEFILE="adovbs.inc"-->
<%
EndConstantDefinition
%>
<%
DimIStandardloopingvar
DimiRecordToUpdateIdofdeletedrecord
Weregoingtokeepthisassimpleaswecan.
1.CreateaRecordsetobject
2.ConnecttheRecordsettothetable
3.Findtherecordtoupdate
4.Updatetherecord
5.Updatethetable
6.ClosetheRecordset
Step1:
DimobjRecordset
SetobjRecordset=Server.CreateObject("ADODB.Recordset")
Step2:
Thesyntaxfortheopencommandis
recordset.OpenSource,ActiveConnection,CursorType,LockType,Options
objRecordset.Open"scratch",DB_CONNECTIONSTRING,adOpenKeyset,adLockPessimistic,adCmdTable
objRecordset.CacheSize=15CutsdownonroundtripstoourSQLServer
Step3:
iRecordToUpdate=CLng(Request.QueryString("id"))
IfiRecordToUpdate0Then
IfNotobjRecordset.EOFThen
objRecordset.MoveFirst
DoUntilobjRecordset.Fields("id")=iRecordToUpdate
objRecordset.MoveNext
Loop
Step4:
Onlyupdateiftheyvetoldusto,o/wweneverrunthis
String/TextDataType
objRecordset.Fields("text_field")=CStr(WeekdayName(WeekDay(Date())))
IntegerDataType
objRecordset.Fields("integer_field")=CInt(Day(Now()))
Date/TimeDataType
objRecordset.Fields("date_time_field")=Now()
Step5:
Onlyupdateiftheyvetoldusto,o/wweneverrunthis
objRecordset.Update
EndIf
EndIf
ShowTable
Feelfreetoskipthisarea.(Ignorethemanbehindthecurtain!)
ImjustshowingtheRSsoyouhavesomethingtolookatwhen
youviewthesample.
Response.Write"<TABLEBORDER=""1""CELLSPACING=""2""CELLPADDING=""2"">"&vbCrLf
Response.WritevbTab&"<TR>"&vbCrLf
Response.WritevbTab&vbTab&"<TD>id</TD>"&vbCrLf
Response.WritevbTab&vbTab&"<TD>text_field</TD>"&vbCrLf
Response.WritevbTab&vbTab&"<TD>integer_field</TD>"&vbCrLf
Response.WritevbTab&vbTab&"<TD>date_time_field</TD>"&vbCrLf
Response.WritevbTab&"</TR>"&vbCrLf
IfNotobjRecordset.EOFThen
objRecordset.MoveFirst
Showdata
DoWhileNotobjRecordset.EOF
Response.WritevbTab&"<TR>"&vbCrLf
ForI=0ToobjRecordset.Fields.Count-1
Response.WritevbTab&vbTab&"<TD><AHREF=""db_update.asp?id="&
objRecordset.Fields("id")&""">"&objRecordset.Fields(I)&"</TD>"&vbCrLf
Next
Response.WritevbTab&"</TR>"&vbCrLf
objRecordset.MoveNext
Loop
EndIf
Response.Write"</TABLE>"&vbCrLf</p>在实现ERP等高端的ASP应用时,用户需要提供核心的经营资料,需要ASP商有很高的信用度。楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。 |
|