Time out issue in classic ASP - sql-server

I am working on a classic ASP project where I am getting time out issue when populating the data from DB and Bind it in the UI. The following error we got:
Script timeout
The maximum amount of time for a script tp execute was exceeded. You can change this limit by specifying new value for the property Server.Scripttimeout or by changing the value in IIS asministration tools
To resolve the issue we tried to do the pagination but it went unsuccessful.
There are several forms on one page with individual names (i.e. form1, form2) . We have implemented Recordset pagination within one particular form.
Along with the pagination edit and delete options are also available for a particular record in record set. The problem what we are facing is when we try to edit the record the form values are not coming to the posted page.
I have mentioned the code snippet as below:
Function someFunction
data1=""
<form name="Xyz" method="post" action="edit.asp">
s=s&"<script>function relsubmit() {alert(" & data1 &"); rjob.submit(); } </script>"
'Pagination code display only 30 records per page
Do While Not ( rss.Eof Or rss.AbsolutePage <> iPage )
'some code
If (Action="RELEdit") Then
s=s&"" & drsel &""
s=s&"
s=s&"" & clean(rss.Fields(4).value) & ""
Else
End If
datadr1=datadr1& rss.Fields(0).value & ","
rss.MoveNext
loop
If (Action="RELEdit") then
s=s&"<input type=hidden name=data1 value=""" & datadr1 & "">"
s=s&"<input type=hidden name=data2 value=""" &datadr2 & """><</form>"
End If
End Function
We have tried to get the value in edit.asp page using request.form("data1") the values are coming empty also we tried alert in the relsubmit() function it is showing as empty.
Can you please help me why the form values are posted as null or empty.
Also, please advise me if we have any other approaches to track the time out.

Place this code at the top of the ASP page you are running.
The values are in seconds (300 = 60*5 = 5 minutes)
This will extend the script runtime to 5 minutes. You can set any value even hours
<%Server.ScriptTimeout=600%>

Related

RPS, windows Form & Revit API (Python)

I've been trying to build a form to create and delete Revit print Sets.
I've 2 main issues:
1) I'm able to create a print set but I cannot access its content unless I restart the Form. I get the errors below (depending if I'm defining the view_set variable or not)
List_object_has_no_attribute_Views
Local_variable_referenced_before_assignment
This is the code of the function to display the sheets of the selected Print Set
def DisplaySheetsInSet (self, sender, args):
self.curItem = CurrentSetsListBox.SelectedItem
PrintSetForm_Load
try:
view_set=[]
for i in PrintSetForm.ViewSets:
if i.Name == str(self.curItem):
view_set = i
else:
continue
Sheets=[sheet.Name for sheet in view_set.Views]
SheetsLb.BeginUpdate()
SheetsLb.Items.Clear()
for sheet in Sheets:
SheetsLb.Items.Add(sheet)
SheetsLb.EndUpdate()
except Exception as e:
popup (str(e)
2) I'm able to delete print sets once. If I try do delete another one I get the following error and I need to restart the form ( code for the function that deletes the print sets shown below)
The_referenced_object_is_not_valid
def DelPrintSet(self, sender, args):
self.curItem = CurrentSetsListBox.SelectedItems
t = Transaction (doc, 'Delete printset')
t.Start()
for viewset in PrintSetForm.ViewSets:
if viewset.Name in [str(item) for item in self.curItem]:
doc.Delete(viewset.Id)
doc.Regenerate()
else:
continue
self.Refresh()
UpdateSetNames(CurrentSetsListBox)
t.Commit()
I've tried to build a function to restart/refresh the Form but it doesn't work (code below):
global PrintSetForm_Load
def PrintSetForm_Load(self, sender):
Application.Exit()
Application.Restart()
#self.Refresh()
#self.ResetBindings()
#self.ActiveForm.Close()
sd = PrintSetForm()
sd.ShowDialog()
This gif shows the form in action:
Manage Print Sets
Any ideas or suggestions?
Thank you.
3) If I try to populate the SheetsLb with a DataSource, just the first set clicked is shown.
Sheets=[sheet.Name for sheet in view_set.Views]
SheetNumber=[sheet.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString() for sheet in view_set.Views]
SheetsLb.BeginUpdate()
SheetsLb.DataSource = None
SheetsLb.Items.Clear()
UpdatedList=[]
for number,name in zip(SheetNumber,Sheets):
UpdatedList.append(number+" - "+ name + " [ ] ")
SheetsLb.DataSource=UpdatedList
SheetsLb.EndUpdate()
1) See if this works:
It would be worth checking that there is something selected in self.viewSetsLb. Ive added a check to the code below
The view_set variable could be initialised as a boolean instead of a list
Using break in the for loop keeps things a little snappier
Ive used the more pythonic for view in PrintSetForm.viewSets rather than for i in PrintSetForm.viewSets - keeping it nice and clear
This code works for me:
self.curItem = self.viewSetsLb.SelectedItem
if not self.viewSetsLb.SelectedItem:
print 'No Printset selected!'
return
view_set = False
for view in PrintSetForm.viewSets:
if view.Name == str(self.curItem):
view_set = view
break
else:
continue
Sheets=[sheet.Name for sheet in view_set.Views]
self.sheetsLb.BeginUpdate()
self.sheetsLb.Items.Clear()
for sheet in Sheets:
self.sheetsLb.Items.Add(sheet)
self.sheetsLb.EndUpdate()
2) Its because the data in your PrintSetForm.ViewSets list is out of date. Every time you change something (ie delete a viewset), repopulate this list:
PrintSetForm.ViewSets = FilteredElementCollector(doc).OfClass(ViewSheetSet).ToElements()
Also, you shouldnt need to build a refresh button, perhaps have a class function that repopulates the Printset list and ListBox, and clears the Sheet ListBox that you call after every action?
Sounds like youre having fun mate!
It sounds as if you have an issue with the scoping and lifetime of variables. For instance, some variables may have a lifetime limited to the form display, and therefore cannot be accessed after the form is closed. You could change the lifetime of these variables, e.g., by making them static class variables instead of local instance variables. I suggest you read up on .net static class variable scope.

How to update some data in SQL server into null for Classic ASP

I want to make update function in a web based system using Classic ASP to enable the user to cancel their application. I'm not using delete function because some data should be maintained, and some data will be set into NULL. This function also allow the user to choose date range in a form to delete their application.
There is no error shown but the set of data is not updated when click on cancel button in the form.
This is the code :
<%param="keyid=" & session("keyid")
idkehadiran=request("idkehadiran")
nokpl=request("nokpl")
set SimpanRS=server.CreateObject("adodb.recordset")
sql="select * from tms_kehadiran where nokpl='"&nokpl&"' and (tarikh >= '"&tarikh&"' and tarikh <= '"&hinggaTarikh&"')"
SimpanRS.open sql,connehr,3,3
while not SimpanRS.EOF
SimpanRS("alasan")=""
SimpanRS("nokpPenyelia")=""
SimpanRS("kelulusan")=null
if isnull(SimpanRS("datecreated")) then
SimpanRS("datecreated")=now
end if
SimpanRS("lastupdate")=now
SimpanRS.update
SimpanRS.movenext
wend
SimpanRS.close
set SimpanRS=nothing
%>
I don't what are the error with this code. Can anyone help me ?
Instead of looping the RS. You should use GetRows().
After that you can update the data in the SQL server while looping the array.

viewcriteria is not working for data having word "and"

i am working with applying view criteria programaticlly, till now it was fine, but when i searched with "develop and unit test" it is showing 0 records even though my table having data. iam using like operator. could any one help on this .
i have one table, having option to filter by providing select combo box list of vales, for every column when i select any thing in lov in value change listener i am applying viewcriteria programatically on table vo.
note. every thing is programatic view object only there is no point of entity, or sql
Sample Code:
DCIteratorBinding bindIterator = ADFUtils.findIterator("Tri2EWS_ETKAPIData_VO1Iterator");//Table viewObject(programatic)
Tri2EWS_ETKAPIData_VOImpl voimpl = (Tri2EWS_ETKAPIData_VOImpl) bindIterator.getViewObject();
ViewCriteria viewCriteria = voimpl.createViewCriteria();
viewCriteria.setName("MyVc");
ViewCriteriaRow viewCriteriaRow = viewCriteria.createViewCriteriaRow();
viewCriteriaRow.setOperator("ViewAttr1", "LIKE");
viewCriteriaRow.setAttribute("ViewAttr1", "stack and OverFlow");
viewCriteria.add(viewCriteriaRow);
viewCriteria.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
voimpl.applyViewCriteria(viewCriteria, true);
voimpl.executeQuery();
voipmpl.getRowCount();//Getting 0 here (Actually i should get 1)
Turn on debug messages for ADF BC (jbo.debugoutput) so you can see the SQL that is being generated.
This will help you figure out if the query is correctly formatted.

ASP, HTML Input i need to return a value not linked with another field

I have a system within my html holiday booking app which prints out an array of holiday requests which look like so.
For i = 0 To Ubound(arrHolsAccept) Step 1
response.Write("<form action=""AdminGUI.asp"" method=""post"">")
Response.write("<tr>")
Response.write("<td>"& "<input type=""hidden"" name=""HolidayID"" value=" &arrHolsAccept(i,0)& " " & "</td>")
Response.write("<td>"& arrHolsAccept(i,1) &"</td>")
Response.write("<td>"& arrHolsAccept(i,2) &"</td>")
Response.write("<td>"& arrHolsAccept(i,3) &"</td>")
Response.write("<td>"& arrHolsAccept(i,4) &"</td>")
Response.write("<td><input type=""submit"" name=""accepthol"" value=""Accept""/><td/>")
Response.write("<td><input type=""submit"" name=""declinehol"" value=""Decline""/><td/>")
Response.write("</tr>")
response.write("<form/>")
Next
the Issue I am having is that the accept and decline buttons within each array item set that is printed out need to pass a value to the database. which is the holiday ID arrHolsAccept(i,0) how can I get these submit and decline buttons to pass this value to the database connection element?
so far my connection element of the system looks as follows
objDBCommand.Parameters.Append objDBCommand.CreateParameter("#HolidayRef", adVarChar, adParamInput,200)
objDBCommand.Parameters.Append objDBCommand.CreateParameter("#EmployeeID", adVarChar, adParamInput,200)
objDBCommand.Parameters.Append objDBCommand.CreateParameter("#jobroleofstaff", adVarChar, adParamInput,200)
objDBCommand("#HolidayRef") = Request.Form("HolidayID")
objDBCommand("#EmployeeID") = Session("userID")
objDBCommand("#jobroleofstaff") = Session("JobroleID")
the submit and decline buttons run this section of code and are supposed to pass it a value. as the array builds the holidays it builds multiple of these submit and decline buttons and I do not know how to differentiate the buttons and then assign the correct holiday ID to them, I have tried multiple things so far and I can't seem to get it to work.
You are already passing the HolidayID / arrHolsAccept(i,0) as a hidden field on this line:
Response.write("<td>"& "<input type=""hidden"" name=""HolidayID"" value=" &arrHolsAccept(i,0)& " " & "</td>")
And you are passing that value to the database stored procedure on this line already:
objDBCommand("#HolidayRef") = Request.Form("HolidayID")
I think the problem you are having is possibly because you are not closing your form. You have an error in your code and need to change this line:
response.write("<form/>")
To:
response.write("</form>")
Put the values of arrHolsAccept(i,1) as the value in a hidden field, comma-separated, then parse it on the server after the form is submitted.

TableAdapter.Update Does Not Save Imported Row

I've hit a problem with my database. The purpose of the section of my application is simple this; when a user marks an assignment of work complete, it will transfer one DataRow from "activeUnits" by using the "table.ImportRow" method to another table called "completedUnits" and then use the table adapter to update this change to the core database. However when testing this function the Dataset has completed the move of rows successfully internally, but upon using the TableAdapter.Update method the update of data to the database returns simply as "0" with no changes made or errors to lead.
Try
Dim activeRowMove As DataRow = Me.AssignmentDataSet.activeUnits.Rows(currentIndex)
Dim newMove As DataTable = Me.AssignmentDataSet.completedUnits
newMove.ImportRow(activeRowMove)
'UPDATE CHANGES
Me.Validate()
CompletedUnitsBindingSource.EndEdit()
Console.WriteLine(Me.CompletedUnitsTableAdapter.Update(Me.AssignmentDataSet.completedUnits))
activeUnitsTitle.Text = ("Assignment Completed!")
Catch ex As Exception
Console.WriteLine("Failed to update new table: " & ex.ToString)
activeUnitsTitle.Text = ("Failed to save!")
End Try
Is there somewhere in my code which I've simply done wrong, or any better or efficient way of moving a datarow is appreciated!
My database is not copied in my project's bin folder and every update goes to one central location.
If needed the following link is two screenshots of my current layout and data - here.
From MSDN:
Calling ImportRow preserves the existing DataRowState along with other values in the row
So, if the DataRowState in your "from" table is Unchanged, then its state will remained Unchanged in the "to" table, and it will not get saved.
Make sure to change the DataRowState of the newly imported row to Added
Cheers

Resources