ASP Programming FAQ (Turn)

Source: Internet
Author: User
Tags date chr html form insert odbc requires
Programming | problem Source:
1. Unable to run ASP correctly
When we have created an ASP file and are compliant, enter the following address through the browser, or through the
Explorer Open Browse:
There will be an error that cannot be run, prompting for incorrect permissions or inaccessible files, because ASP files first
Requires the site to have the Execute (script) attribute, and then requires that the address be entered in the URL format without
is a DOS format, so please correct both of these errors.

2. The database cannot be accessed after the program moves location
This error is first in ODBC, if the ODBC data source is set correctly, then you need to be aware that the ASP opens the database
Command: The Conn.Open parameter is correct. If you are correct, you need to be aware of whether you are using the global
The. Asa file, which is the configuration file for the ASP connection database, which reads as follows:
<script language= "VBScript" runat= "Server" >
' You can add special event handlers in this file ' would get run aut
omatically when special Active Server Pages Events
' occur. To create this handlers, just create a subroutine with a name
From the list below this corresponds to the event
' You want to use. For example, to create a event handler for Session_
OnStart, you would put the following code in this
' File (without the comments):
' EventName Description
' Session_OnStart runs the ' A user runs any page in your APPL
' Session_OnEnd runs when a user's session times out or quits your APPL
' Application_OnStart runs once when the ' the ' the ' your application
is run for the
' Application_OnEnd runs once the Web server shuts down

<script Language=vbscript runat=server>
Sub Session_OnStart
' ==visual InterDev generated-dataconnection startspan==
'--project Data Connection
Session ("customers_connectionstring") = "Driver={sql Server}"; Server= (Loc
AL); Uid=sa; pwd=; App=microsoft (R) Developer Studio; Wsid=gregleak;databas
E=customers "
Session ("customers_connectiontimeout") = 15
Session ("customers_commandtimeout") = 30
Session ("customers_runtimeusername") = "sa"
Session ("Customers_runtimepassword") = ""
' ==visual InterDev generated-dataconnection endspan==
End Sub
Be aware of the DSN in which the server must be the name of the database servers, and if that is not correct, you need to
To correct. The other is whether the UID and PWD are correct, and if the open command uses session, you need
Session ("customers_runtimeusername") = "sa"
Session ("Customers_runtimepassword") = ""
is correct.

3. Use of runat
In the script syntax, there is a runat parameter that indicates whether the script is running on the server or on the client.
If there is a runat=server the script runs on the server, the ASP interpreter interprets the execution, and the knot
The results are passed to the WWW server, otherwise it is run on the client and interpreted by the browser's script virtual machine.
, which is no different from the general script. Therefore, be sure to note the commands in the ASP syntax, such as: REQ
Uest,querystring,write commands or objects must run in scripts with runat parameters;
The script for the HTML form object must not have runat parameters, because the HTML form is the client side of the
Like, the server is inaccessible.

4. Unable to insert Date field into SQL Server
If you encounter situations in which you must insert dates by using the U.S. date format, you need to set the
Set China long date format, please pay special attention, ASP is running on the server, the resulting HTML knot
The results are passed to the browser, so all formatting must be on the server.

5. How to push a message to a client
If you are judging access errors on the server, such as registration failures, unauthorized action records, and so on, you need to prompt the user
of information. This information needs to be pushed to the client and a prompt window appears, which is a frequent problem
。 This time, you must use the dynamic page way, because the error is judged on the server, and prompts
appears on the browser. We can use the following ASP to push the error:
On Error Resume Next
Conn=server.createobject ("Adodb.connection")
Conn.Open "Pubs", "Wlf", ""
' If registration fails, the error number is greater than 0
If Conn.errors.count>0 Then
' The following code generates a scripting language on the client computer that is provided to the browser to perform
Response.Write "<script language=javascript>" & Chr (13)
Response.Write "{" & Chr (13)
Response.Write "Window.alert (" you are not authorized to access the database!) ")" & Chr (13)
Response.Write "}" & Chr (13)
Response.Write "</script >" & Chr (13)
End If

6. Clients try to use fixed IP addresses
Because the ASP connection database is timed, the default is:
Session ("customers_connectiontimeout") = 15
Session ("customers_commandtimeout") = 30
Two settings determine the time, automatically disconnect after timeout, so when refreshing the page to rerun ASP code
, if the IP allocation time is not enough (dynamic IP allocation takes time, much longer than static!) ), you may not
Connection, an error message appears, so try to use a static IP address.

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: 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.