Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

i face this error in VS 2010 ,incorrect Syntax near '8' when i use Insert query

$
0
0

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();
                }
            }



Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>