Find the mistakes in the following ASP.Net code:
<@ Find the mistakes @>
<%@ Page Language=VB %>
<%@ Using Namespace=System.IO %>
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<script >
public button1Click(int source, eventergs e)
{
OleDbConnection c = new Connection();
c.ConnectionString = Provider=Microsoft Jet OLEDB 4.0; +
Data Source=c:ectweb2\Database\persons.mdb;
var sql = INSERT INTO Persons VALUES +
(' + T1.Text + ', ' + T2.Text + , +
integer.parseInt(t3.Text) + );;
OleDbCommand conn = new Command(sql, comm);
comm.ExecuteQuery();
// See previous problem for code to populate the controls.
}
</script>
<htm xmlsn=http://www.w3.org/1999/xhtml >
<head runat=server>
<title=Find Mistakes />
<link href=styles.css ref=stylesheet type=css\txt />
</head>
<body>
<form id=form1 runat=server>
<div>
<p><asp:Button ID=Button1 runat=server
Text=Button CssClass=.orange
Click=Button1_Click</p>
<p><asp:TextBox ID=T1 runat=server
CssClass=.orange />
<asp:Label ID=Label1 runat=server
CssClass=.orange Text=Name /></p>
<p><asp:TextBox ID=T2 runat=server
CssClass=.orange />
<asp:Label ID=Label2 runat=server
CssClass=.orange Text=Gender />
<p><asp:TextBox ID=T3
CssClass=.orange />
<asp:Label ID=Label3
CssClass=.orange Caption=Age /></p>
</form>
</htm>
Here is the corrected code:
<%-- Find the mistakes --%>
<%@ Page Language=C# %>
<%@ Import Namespace=System.Data %>
<%@ Import Namespace=System.Data.OleDb %>
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<script runat=server>
public void Button1_Click(object source, EventArgs e)
{
OleDbConnection c = new OleDbConnection();
c.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0; +
Data Source=c:\\Database\\persons.mdb;
string sql = INSERT INTO Persons VALUES +
(' + T1.Text + ', ' + T2.Text + , +
int.Parse(T3.Text) + );;
OleDbCommand comm = new OleDbCommand(sql, c);
comm.ExecuteNonQuery();
}
</script>
<html xmlsn=http://www.w3.org/1999/xhtml>
<head id=Head1 runat=server>
<title>Find Mistakes</title>
<link href=styles.css ref=stylesheet type=text/css />
</head>
<body>
<form id=form1 runat=server>
<div>
<p><asp:Button ID=Button1 runat=server
Text=Button CssClass=orange
Click=Button1_Click /> </p>
<p><asp:TextBox ID=T1 runat=server
CssClass=orange />
<asp:Label ID=Label1 runat=server
CssClass=orange Text=Name /></p>
<p><asp:TextBox ID=T2 runat=server
CssClass=orange />
<asp:Label ID=Label2 runat=server
CssClass=orange Text=Gender /></p>
<p><asp:TextBox ID=T3 runat=server
CssClass=orange /></p>
<p><asp:Label ID=Label3 runat=server
CssClass=orange Text=Age /></p>
</form>
</html>