On the MIS system is very convenient, first of all, it borrowed ADO technology and concepts, while access to the database through ODBC, to achieve full flexibility and multi-platform, in addition, because the ASP use the VBS and JS scripting language, but also ensure that most developers quickly into the development process, reducing the learning process.
However, because the ASP is based on the Internet/intranet way, it and the traditional C/s structure is different after all, so in the development of the attention of some details. This article describes some of the common problems and gives a solution.
Problem description
A. Unable to run ASP correctly
When we have created an ASP file, and the syntax is in place, enter the following address through the browser, or open browsing through the Explorer:
C:/inetpub/wwwroot/a.asp
An error that cannot be run is prompted and the permissions are not correct or the file is inaccessible because the ASP file first requires the site to have the Execute (script) attribute, and then requires that the address be entered in the URL format instead of the DOS format, so please correct both errors.
B. 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 of the command to open the database in asp: Conn.Open parameters are correct. If correct, you need to be aware of using the Global.asa file, which is the configuration file for the ASP connection database, which reads as follows:
<script language= "VBScript" runat= "Server" >
' Can add special event handlers in this file ' would get run automatically when special Active Server Pages Events
' occur. To create this handlers, just create a subroutine with a name from the ' list below that ' corresponds to the event
' You want to use. For example, to create a event handler for Session_OnStart, your would put the "following code into"
' File (without the comments):
' EventName Description
' Session_OnStart runs the ' A user runs any page in your application
' Session_OnEnd runs when a user's session times out or quits your application
' Application_OnStart runs once when the ' the ' the ' the ' the ' the ' the ' the ' the ' the ', '
' Application_OnEnd runs once the Web server shuts down
</script>
<script language=vbscript runat=server>
Sub session_onstart
' ==visual InterDev Generated-dataconnection startspan==
'--project Data Connection
Session ("customers_connectionstring") = " Driver={sql Server}; server= (local); Uid=sa; pwd=; App=microsoft (R) Developer Studio; Wsid=gregleak;database=customers '
session (' customers_connectiontimeout ') =
Session ("Customers_ CommandTimeout ") =
Session (" customers_runtimeusername ") =" SA "
Session (" Customers_runtimepassword ") =" "
' ==visual InterDev generated-dataconnection endspan==
End Sub
</script>
Note the DSN in it. In which server must be the name of the database server, if the place is not correct, you need to correct. Also, if the UID and PWD are correct, and if the open command uses session, you need to be aware that the
session ("customers_runtimeusername") = "SA"
Session ("Customers_ Runtimepassword ") =" "
is correct.
C. Runat use problems
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 are runat=server the script runs on the server, the ASP interpreter interprets the execution and delivers the results 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 normal script. So be sure to pay attention to the commands in the ASP syntax, such as: Request,querystring,write commands or objects must run in scripts with runat parameters, while scripts that access HTML form objects must have no runat parameters. Because the HTML form is a client-side object, the server cannot access it.
D. Cannot insert a date field into SQL Server
If you encounter a situation in which you must insert a date in the U.S. date format, you need to set the Chinese long date format on the server's locale, especially note that the ASP is running on the server and the resulting HTML results are passed to the browser, so all formatting must be on the server.
E. 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 need to prompt the user's information. This information needs to be pushed to the client and a prompt window appears, which is a recurring problem. This time, you must use a dynamic page, because the error is judged on the server, and the hint appears in 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
F. 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 the Refresh page to execute ASP code, if the IP allocation time is not enough (dynamic IP allocation takes time, much longer than static.) may not be able to connect, an error message appears, so try to use a static IP address.
Summarize
The
Programming with ASP is convenient. As ADO across the ODBC, the formation of a multi-threaded processing capacity of the database operation, and is running on the server, although increased the pressure on the server, but now the server (even the PC server) processing capacity is very strong, so as to play the efficiency of the server. In addition, because the ASP can and ActiveX control a good interface, but also make it easier for developers to expand the program according to their own needs, and directly based on the ASP programming environment, the only thing to be aware of is that the idea of internet/intranet must be designed and written procedures, otherwise it will be wasted.