assalamo alykom
this is a web server code linked with a database in order to serch for certain query and return the output please can anyone check the syntax of the code ,i'm really new to this programming language and i'll be happy if u help me and tell me the error or u can post it with the correction and i'll find the errors my self.
thanks in advance
here is hte code
using System;
using System.IO;
using System.Data.OleDb;
namespace aromrFMP
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.OleDb.OleDbConnection oleDbConnection1;
private OleDbCommand SQL=new OleDbCommand();
private string a,path;
private void Page_Load(object sender, System.EventArgs e)
{
try
{
a=Request.QueryString.Get(0);
}
catch(ArgumentOutOfRangeException AOORE)
{
Response.Write("No Given Data...");
return;
}
SQL.Connection=oleDbConnection1;
Process(a);
oleDbConnection1.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
this.path=Server.MapPath("bin\\aromrFMP.mdb");
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString ="Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=0;Data Source=\""+path+"\";Jet OLEDB:Engine Type=5;Provider=\"Microsoft.Jet.OLEDB.4.0\";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=ReadWrite;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";
this.Error += new System.EventHandler(this.WebForm1_Error);
this.Unload += new System.EventHandler(this.WebForm1_Unload);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private string Execute(string reqField)
{
try
{
oleDbConnection1.Open();
OleDbDataReader dr=SQL.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
return dr[reqField].ToString();
}
}
catch(OleDbException r){oleDbConnection1.Close();}
finally
{
oleDbConnection1.Close();
}
return "Not Found";
}
private void Process(string req)
{
if (req[0]=='1')
GetMyLec(req.Substring(1));
else if (req[0]=='2')
TakeMe(req.Substring(1));
else if (req[0]=='3')
TimeTable(req.Substring(1));
else if (req[0]=='4')
ExamTable(req.Substring(1));
else if (req[0]=='5')
EmptyRoom(req.Substring(1));
else if (req[0]=='6')
Result(req.Substring(1));
else if (req[0]=='7')
Reserve(req.Substring(1));
else if (req[0]=='8')
BinNum(req.Substring(1));
else if (req[0]=='9')
ExamPlace(req.Substring(1));
}
private void GetMyLec(string Data)// first function
{
if (Data[0]=='0'),
{
SQL.CommandText="SELECT [TimeTable2].[Place]
FROM TimeTable INNER JOIN TimeTable2 ON [TimeTable].[Session4]=[TimeTable2].[Session]
WHERE ((([TimeTable].[Group])="+Data.Substrin(1,6)") AND (([TimeTable].[Day])="+Data.Substring(6,11)+") AND (([TimeTable].[SecId])="+Data.Substring(11,13)+") AND (([TimeTable].[Session4])="electronics") AND (([TimeTable2].[Session])="electronics"));
";}
string Table=Execute("Table");
if (Table==null||Table==""||Table=="Not Found")
{
Response.Write("Not Found");
return;
}
else
Response.Write(Execute("Table"));}//end first function
//second function
private void TakeMe(string Data)
{
SQL.CommandText="
SELECT [Location].[Building], [Location].[Floor]
FROM Location
WHERE ((([Location].[Palce])="+Data.Substring(1,5)+"));";
Response.Write(Execute("Building"));
Response.Write(Execute("Floor"));
}
//end second function
//third function
private void ExamTable(string Data)
{SQL.CommandText="
SELECT [ExamTable1].[Day], [ExamTable].[Material], [ExamTable].[Time], [ExamTable].[Date]
FROM ExamTable1 INNER JOIN ExamTable ON ExamTable1.Day = ExamTable.Day
WHERE ((([ExamTable1].[Group])="+Data.Substring(1,6)+"));";
Response.Write(Execute("Day"));
Response.Write(Execute("Material"));
Response.Write(Execute("Time"));
Response.Write(Execute("Date"));
}
//fourth function
private void TimeTable(string Data)
{SQL.CommandText="
SELECT [TimeTable].[Day], [TimeTable].[SecId], [TimeTable].[Session1], [TimeTable].[Session2], [TimeTable].[Session3], [TimeTable].[Session4], [TimeTable].[Session5], [TimeTable].[Session6], [TimeTable1].[SecId]
FROM TimeTable INNER JOIN TimeTable1 ON TimeTable.Group=TimeTable1.Group
WHERE (((TimeTable.Group)="+Data.Substring(1,6)+") AND ((TimeTable.SecId)="+Data.Substring(6,8)+") AND ((TimeTable1.Group)="+Data.Substring(1,6)+") AND ((TimeTable1.SecId)=+Data.Substring(6,8)+));";
Response.Write(Execute("Day"));
Response.Write(Execute("Session1"));
Response.Write(Execute("Session2"));
Response.Write(Execute("Session3"));
Response.Write(Execute("Session4"));
Response.Write(Execute("session5"));
Response.Write(Execute("session6"));
}
//fifth function
private void EmptyRoom(string Data)
{SQL.CommandText="
SELECT [ Reservation].[Place], [Reservation].[Date], [Reservation].[Session]
FROM Reservation
WHERE (((Reservation.Date)="+Data.Substring(1,6)+") AND ((Reservation.Status)=""+Data.Substring(6,12)+"));";
Response.Write(Execute("Date"));
Response.Write(Execute("Session"));}
//6th function
private void BinNum(string Data)
{
SQL.CommandText="SELECT [Student].[Bin]
FROM Student
WHERE (((Student.StId)="+Data.Substring(6,12)+"));";
Response.Write(Execute("Student"));}
//7th function
private void ExamPlace(string Data)
{SQL.CommandText="SELECT [ExamPlace].[Place]
FROM ExamPlace
WHERE (((ExamPlace.Binfrom)>"+Data.Substring(1,5)+") AND ((ExamPlace.Binto)<"+Data.Substring(5,10)+"));";
Response.Write(Execute("Place"));}
//8th function
private void Result(string Data)
{SQL.CommandText="SELECT [Results].[Grade], [Results].[TotalNo]
FROM Results
WHERE (((Results.Bin)="+Data.Substring(1,3)+"));";
Response.Write(Execute("Grade"));
Response.Write(Execute("TotalNo"));}
//9th function
private void BusService(string Data)
{SQL.CommandText="
SELECT [BusService].[Name], [BusService].[Station1], [BusService].[Station2], [BusService].[Station3]
FROM BusService1 INNER JOIN BusService ON BusService1.Id=BusService.Id
WHERE (((BusService.Name)="+Data.Substring(1,7)+"));";
Response.Write(Execute("Station1"));
Response.Write(Execute("Station2"));
Response.Write(Execute("Station3"));
}
private void WebForm1_Error(object sender, System.EventArgs e)
{
oleDbConnection1.Close();
}
private void WebForm1_Unload(object sender, System.EventArgs e)
{
oleDbConnection1.Close();
}
}
}

