this fucntion calls query method
private static void CreateStudent(StudentHandle ObjStudent)
{
String ConectionString = Properties.Settings.Default.Database1ConnectionString;
String query="INSERT into STUDENT (RegNo,Batch,StudentName,Address,StudentPhone,DOB,Email,HomePage,"+
"FatherName,FatherOffice,FatherCell,MotherName,MotherOffice,MotherCell,ResPhone,ResAddress,"+
"AdmissionDate,AdmittedBy,PreviousInstituteName,PreviousInstituteAddress,PreviousInstituePhone,"+
"PreviousInstituteLeaReason) Values ("+ObjStudent.RegNo+",'"+ObjStudent.Batch+"','"+ObjStudent.StudentName+"','"+ObjStudent.StudentAddress+
"',"+ObjStudent.StudentPhone+",'"+ObjStudent.StudentDOB+"','"+ObjStudent.StudentEmail+"','"+ObjStudent.StudentHomePage+
"','"+ObjStudent.FatherName+"',"+ObjStudent.FatherOffice+","+ObjStudent.FatherCell+",'"+ObjStudent.MotherName+
"',"+ObjStudent.MotherOffice+","+ObjStudent.MotherCell+","+ObjStudent.ResidencePhone+",'"+ObjStudent.ResidenceAddress+
"','"+ObjStudent.AdmissionDate+"','"+ObjStudent.AddmittedBy+"','"+ObjStudent.PreInsName+"','"+ObjStudent.PreInsAddress+
"',"+ObjStudent.PreInsPhone+",'"+ObjStudent.PreInsLeareason+"')";
QueryHandle.ExcuteNonQuery(ConectionString,query);
}
// these are two methods for Query handling
public static DataTable ExcuteQuery(String conStr, String query, String tableName)
{
try
{
SqlConnection MyConection = new SqlConnection(conStr);
SqlDataAdapter Da = new SqlDataAdapter(query, MyConection);
DataSet ds = new DataSet();
Da.Fill(ds, tableName);
ds.Tables[0].TableName = tableName;
return ds.Tables[0];
}
catch (Exception ex)
{
string message = ex.Message;
throw ex;
}
}
public static void ExcuteNonQuery(String ConectionString, String Query)
{
SqlConnection myconection = new SqlConnection(ConectionString);
try
{
myconection.Open();
SqlCommand mycommand = new SqlCommand(Query,myconection);
mycommand.ExecuteNonQuery();
}
catch (Exception ex)
{
string message = ex.Message;
throw ex;
}
finally
{
if (myconection.State == ConnectionState.Open)
{
myconection.Close();
}
}
}