本文介绍了ExecuteNonQuery()在存储过程中始终返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,


我写了一个更新记录的代码,执行后总是返回0.

请帮帮我.
我的代码是..

Hello Friends,


I wrote a code for updating the record ,after executing it is always return 0.

Please Help me.
My Code is..

bool isresult = false;
            string connectionInfo = ConfigurationSettings.AppSettings["ConnectionString"];
            SqlConnection ObjSqlConnection = new SqlConnection(connectionInfo);
            ObjSqlConnection.Open();
            SqlTransaction ObjSqlTransaction = ObjSqlConnection.BeginTransaction();
            SqlCommand objSqlCommand = new SqlCommand("SP_UpDateDetails", ObjSqlConnection, ObjSqlTransaction);
            objSqlCommand.CommandType = CommandType.StoredProcedure;
            objSqlCommand.CommandTimeout = 500000;
            try
            {


                objSqlCommand.Parameters.Add("@regId", SqlDbType.VarChar).Value = (objCO_TR_Registration.RegistrationID);

                objSqlCommand.Parameters.Add("@SSLCNO", SqlDbType.VarChar).Value = (objCO_TR_Registration.SSLCNo);
               // objSqlCommand.Parameters.Add("@photo", DbType.Byte).Value = objCO_TR_Registration.Photo;

                //objSqlCommand.Parameters.Add("@VLFNO", SqlDbType.VarChar).Value = (objCO_TR_Registration.VLFNO);
                objSqlCommand.Parameters.Add("@Stud_name", SqlDbType.VarChar).Value = objCO_TR_Registration.Name;
                objSqlCommand.Parameters.Add("@FHG", SqlDbType.VarChar).Value = objCO_TR_Registration.FHG;
                objSqlCommand.Parameters.Add("@FHG_Name", SqlDbType.VarChar).Value = objCO_TR_Registration.FatherName;
                objSqlCommand.Parameters.Add("@Gender", SqlDbType.VarChar).Value = objCO_TR_Registration.gender;
                objSqlCommand.Parameters.Add("@MaritalStatus", DbType.String).Value = objCO_TR_Registration.MaritalStatus;

                objSqlCommand.Parameters.Add("@DOB", SqlDbType.VarChar).Value = objCO_TR_Registration.DateOfBirth;
                objSqlCommand.Parameters.Add("@Religion", SqlDbType.Char).Value = objCO_TR_Registration.ReligionId;
                objSqlCommand.Parameters.Add("@Income", SqlDbType.Decimal).Value = objCO_TR_Registration.AnnualIncome;

                objSqlCommand.Parameters.Add("@Address1", SqlDbType.VarChar).Value = objCO_TR_Registration.Address1;
                objSqlCommand.Parameters.Add("@Address2", SqlDbType.VarChar).Value = objCO_TR_Registration.Address2;
                objSqlCommand.Parameters.Add("@Pre_distCode", SqlDbType.Int).Value = objCO_TR_Registration.Pre_DistrictId;
                objSqlCommand.Parameters.Add("@Pre_talukcode", SqlDbType.Int).Value = objCO_TR_Registration.Pre_Taluq;
                objSqlCommand.Parameters.Add("@pinCode", SqlDbType.Int).Value = objCO_TR_Registration.PinCode;
                objSqlCommand.Parameters.Add("@PhoneNo", SqlDbType.NVarChar).Value = objCO_TR_Registration.PhoneNo;
                objSqlCommand.Parameters.Add("@MoblieNo", SqlDbType.VarChar).Value = objCO_TR_Registration.MobileNo;
                objSqlCommand.Parameters.Add("@EmailID", SqlDbType.VarChar).Value = objCO_TR_Registration.EmailId;
                objSqlCommand.Parameters.Add("@PAddress1", SqlDbType.VarChar).Value = objCO_TR_Registration.PAddress1;
                objSqlCommand.Parameters.Add("@PAddress2", SqlDbType.VarChar).Value = objCO_TR_Registration.PAddress2;

                objSqlCommand.Parameters.Add("@Per_distCode", SqlDbType.VarChar).Value = objCO_TR_Registration.Per_DistrictId;
                objSqlCommand.Parameters.Add("@Per_taluk", SqlDbType.VarChar).Value = objCO_TR_Registration.Per_Taluq;

                objSqlCommand.Parameters.Add("@ppinCode", SqlDbType.Int).Value = objCO_TR_Registration.PPinCode;
                objSqlCommand.Parameters.Add("@pPhoneNo", SqlDbType.NVarChar).Value = objCO_TR_Registration.PPhoneNo;
                objSqlCommand.Parameters.Add("@pMoblieNo", SqlDbType.Int).Value = "0";
                objSqlCommand.Parameters.Add("@College", SqlDbType.Int).Value = objCO_TR_Registration.CollegeId;
                objSqlCommand.Parameters.Add("@Course", SqlDbType.Int).Value = objCO_TR_Registration.CourseId;
                objSqlCommand.Parameters.Add("@Branch", SqlDbType.VarChar).Value = objCO_TR_Registration.branch;

                objSqlCommand.Parameters.Add("@Cduration", SqlDbType.Int).Value = objCO_TR_Registration.Cduration;
                objSqlCommand.Parameters.Add("@WhichYear", SqlDbType.Int).Value = objCO_TR_Registration.WhichYear;
                objSqlCommand.Parameters.Add("@Amount", SqlDbType.Decimal).Value = (objCO_TR_Registration.FeeAmount);
                objSqlCommand.Parameters.Add("@TotalAmount", SqlDbType.Decimal).Value = (objCO_TR_Registration.TotalAmount);
                objSqlCommand.Parameters.Add("@fOccupation", SqlDbType.VarChar).Value = objCO_TR_Registration.foccupation;
                objSqlCommand.Parameters.Add("@mOccupation", SqlDbType.VarChar).Value = objCO_TR_Registration.moccupation;
                objSqlCommand.Parameters.Add("@gOccupation", SqlDbType.VarChar).Value = objCO_TR_Registration.goccupation;
                objSqlCommand.Parameters.Add("@Otherloan", SqlDbType.VarChar).Value = objCO_TR_Registration.OtherLoan;
                objSqlCommand.Parameters.Add("@AcademicYear", SqlDbType.Int).Value = objCO_TR_Registration.AccademeicYear;

                int res = objSqlCommand.ExecuteNonQuery();
}
catch(Exception Ex)

推荐答案


这篇关于ExecuteNonQuery()在存储过程中始终返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 08:24