ASP Universal Data Manipulation function

Source: Internet
Author: User
Tags table name

I was through arduous hardships, Ba Shan Wade Ah, finally finished this page, but this also want to thank the JSP, because yesterday when the whim, suddenly want to learn JSP, so find a few articles, after reading feel javabean too cow x, Feel a bit like I usually write ASP when the processing mode: is a page layout, another background processing.

Just in time to see a common approach to it, so I also designed an ASP, but only in the SQL Server, because I often use SQL database.

I wrote the following page, please advise!

When used, you can write in the Submit form:

which

TBL: To manipulate the name of the datasheet

KEYV: For conditional statements, multiple conditions can be separated by $

On Error Resume Next
Dim keya,condition,temp ' Temporary Variable
Dim insstr,insstr1,insstr2,delstr,updstr,rltstr
Tbl=request. QueryString ("TBL") ' Table name
Keyv=request. QueryString ("Keyv") ' Key field name
Condition= ""
Keya=split (KEYV, "$")
For all I in Keya
If temp<> "" Then
End If
Condition=left (Condition,len (condition)-5)
'----------manipulate the database
Dbconn.open ConnStr ' connstr is a database connection string.
sqlstr= "exec a_tblinfo '" &tbl& ""
'---------recordset is null processing
Response. Clear ()
Response. End ()
'---------------------------insert operation
insstr1= INSERT INTO [&tbl&] ("
While not dbrst.eof
Fldv=request. Form (FLD)
insstr1=insstr1&fld& ","
End If
Wend
Rltstr= ""
Rltstr=left (Insstr1, (Len (INSSTR1)-1)) & ")" &left (Insstr2, (Len (INSSTR2)-1)) & ")"
'---------------------------Modify operation
updstr= "Update [" &tbl& "] set"
Fld=dbrst ("name")
If fldv<> "" and Dbrst ("Colstat") <>1 Then
End If
Wend
Rltstr= ""
Rltstr=left (Updstr, (Len (UPDSTR)-1)) &condition
'---------------------------Delete operation
delstr= "Delete from [&tbl&]"
Response. Clear ()
Response. End ()
'-------processing data records
Dbconn.execute Rltstr
Dbrst.close
Dbconn.close
%>
'----CursorTypeEnum Values----
' Const adOpenKeyset = 1
' Const adOpenStatic = 3
'----LockTypeEnum Values----
' Const adlockpessimistic = 2
' Const adlockbatchoptimistic = 4

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.