Recommended: Multiple repeated submissions of restricted forms in ASP On the Internet, we encounter countless forms every day, and we also see that most of them do not restrict users from submitting the same form multiple times. The lack of such restrictions can sometimes produce some unexpected results, such as duplicate subscription to email services or duplicate voting. This article introduces a simple method in ASP applications to prevent users from submitting the same form multiple times during the current session
Batch entry is widely used in databases, and there are many methods for batch entry. Next, I will talk about how I achieved it based on my actual application. The main use is the concept of form collection, which takes all the data in the collection through loop. Considering that it is convenient for everyone to see, I integrated it into one page.
Here is the specific code:
| The following is the quoted content: <% 'Write data to the database SUB writeData() dim recCnt,i dim fieldName1,fieldName2,fieldName3 dim conn dim sqlStr,connStr connStr=Provider=SQLOLEDB.1;Initial Catalog=myDatabase;Data Source=myhon;User Id=sa;PASSWORD= set conn=Server.CreateObject(ADODB.Connection) conn.open connStr 'Create a database connection recCnt=request.form(stu_num).count 'How many records are there in total 'Batch input data for i=1 to recCnt fieldName1=trim(request.form(fieldName1)(i)) fieldName2=trim(request.form(fieldName2)(i)) fieldName3=trim(request.form(fieldName3)(i)) sqlStr=insert into myTable(fieldName1,fieldName2,fieldName3) values( ' sqlStr=sqlStr & fieldName1 & ', ' sqlStr=sqlStr & fieldName2 & ', ' sqlStr=sqlStr & fieldName3 & ') 'response.write sqlStr conn.execute(sqlStr) next END SUB 'Show batch input interface SUB InputData() dim recCnt,i %> <form name=bathInputData action= method=post> <% recCnt=cint(request.form(recCnt)) for i=1 to recCnt %> <input type=text name=fieldName1> <input type=text name=fieldName2> <input type=text name=fieldName3> <% next %> <br> <input type=submit name=action value=submit> </form> <% END SUB 'Specify how many records to be entered in batches SUB assignHowMuch() %> <!------Specify how many records to enter-----------------------> <form name=form1 action= method=post> The number of records you want to enter: <input type=text name=recCnt> <input type=submit name=action value=next>>> </form> <% END SUB if request.form(action)=Next>> then Call InputData() 'Show batch entry interface elseif request.form(action)=Commit then Call writeData() 'Batch write data to the database else Call assignHowMuch() 'Show the interface that specifies how many records to be entered end if %> |
Share: Solutions for ASP multiple query We often encounter multiple query problems, and long SQL statements often make monks confused. Especially when the client part fills in query conditions, it will be even more difficult to use ordinary methods. The following cleverly uses the identity of where 1=1 (in fact, it's a lot, just let it have a value of TRUE) to solve this problem. Text summary 'subject information title'com