Differences Between ASP & ASP.NET Well Explained:
The most important difference between ASP and ASP.Net is that ASP uses
interpreted VBScript or JScript, and ASP.net uses any .Net language
(including VB.Net, C#, J#, etc.) compiled.
ASP 3.0 left all its code in the front of the application. There was
no way for a programmer to "hide" the sensitive code which he or she may
not want anybody to see. The fact that the code was interpreted also
slowed performance. ASP.NET allows the programmer to create dynamic link
libraries containing the sensitive code. This may be a disadvantage
from an open-source perspective but compiling code into dll's greatly
improves performance.
ASP.NET is firmly rooted in XML. Customarily, the dlls that ASP.NET
creates start out as namespaces. All of the classes in the namespaces
are then compiled into a single dll binary.
- ASP is mostly written using VB Script and HTML intermixed. Presentation and business logic is intermixed while ASP.NET can be written in several .NET compliant languages such as C# or VB.NET.
- ASP has maximum of 4 built in classes like Request, Response, Session and Application whereas ASP.NET using .NET framework classes which has more than 2000 in built classes.
- ASP does not have any server based components whereas ASP.NET offers several server based components like Button, TextBox etc. and event driven processing can be done at server.
- ASP doesn't support Page level transactions whereas ASP.NET supports Page level transactions.
- ASP.NET offers web development for mobile devices which alters the content type (wml or chtml etc.) based on the device.
- ASP.NET allows separation of business and presentation logic because the code need not be included directly in the *.aspx page.
- ASP.NET uses languages which are fully object oriented languages like C# and also supports cross language support.
- ASP.NET offers support for Web Services and rich data structures like DataSet which allows disconnected data processing.
Let me show you one sample in ASP to perform SQL action:
In this tutorial I will show you how to connect to MS SQL Server database. Everything is commented(in ASP we Comment as ') so you won't have trouble.
Connect with a DSNDSN stands for 'Data Source Name'. It is an easy way to assign useful and easily rememberable names to data sources which may not be limited to databases alone. If you do not know how to set up a system DSN read this tutorial How to set up a system DSN.
<%
'declare the variables
Dim Connection
Dim Recordset
Dim SQL
'declare the SQL statement that will query the database
SQL = "SELECT * FROM TABLE_NAME"
'create an instance of the ADO connection and recordset objectsSet Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'open the connection to the database
Connection.Open "DSN=dsn_name;UID=user_name;PWD=password;Database=database_name"
'Open the recordset object executing the SQL statement and return records Recordset.Open SQL,Connection
'first of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else
'if there are records then loop through the fields
Do While NOT Recordset.Eof
Response.write Recordset("FIRST_FIELD_NAME")
Response.write Recordset("SECOND_FIELD_NAME")
Response.write Recordset("THIRD_FIELD_NAME")
Response.write "<br>"
Recordset.MoveNext
Loop
End If
'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
Connect without a DSN (using a connection string)Let’s look at a sample script to get an idea how to connect to MS SQL Server database without DSN:
<%
'declare the variables
Dim Connection
Dim ConnString
Dim Recordset
Dim SQL
'define the connection string, specify database driver
ConnString="DRIVER={SQL Server};SERVER=yourServername;UID=yourUsername;" & _
"PWD=yourPassword;DATABASE=yourDatabasename"
'declare the SQL statement that will query the database
SQL = "SELECT * FROM TABLE_NAME"
'create an instance of the ADO connection and recordset objectsSet Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'Open the connection to the database
Connection.Open ConnString
'Open the recordset object executing the SQL statement and return records Recordset.Open SQL,Connection
'first of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else 'if there are records then loop through the fields
Do While NOT Recordset.Eof
Response.write Recordset("FIRST_FIELD_NAME")
Response.write Recordset("SECOND_FIELD_NAME")
Response.write Recordset("THIRD_FIELD_NAME")
Response.write "<br>"
Recordset.MoveNext
Loop
End If
'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
No comments:
Post a Comment