this is my code for query and query handling
any solution?
private static void CreateStudent(StudentHandle ObjStudent)
{
String ConectionString = Properties.Settings.Default.Database1ConnectionString;
String query="INSERT into STUDENT (Id,RegNo,Batch,StudentName,Address,StudentPhone,Date,Email,HomePage,"+
"FatherName,FatherOffice,FatherCell,MotherName,MotherOffice,MotherCell,ResPhone,ResAddress,"+
"AdmissionDate,AdmittedBy,PreviousInstituteName,PreviousInstituteAddress,PreviousInstitutePhone,"+
"PreviousInstituteLeaReason) Values ("+ObjStudent.Id+","+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);
}
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();
}
}