[Message Deleted]
joynee
Posts
-
null reference exception not set to create an object instance -
null reference exception not set to create an object instancei have a number in my table that i need to inser in the database.the loop is returning a null value.how to convert object to string .here is my code. can anyone help on this.. using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OracleClient; /// <summary> /// Summary description for TMPerminent /// </summary> public class TMPerminent { #region Variables OracleConnection con; #endregion #region CONNECTION STRING public string connectionString = System.Configuration.ConfigurationManager.AppSettings["OracleConnectionString2"]; # endregion public TMPerminent() { OracleConnection con = new OracleConnection(connectionString); } //public void AddNewRow(DataRow gvWeekDays,DataRow gvHrsNewRow, DataRow gvTaskNewRow, string strTWODID,string strEmpTSID) public void AddNewRow(string dayid, string dayhrs, ref DataRow gvTaskNewRow, string strTWODID, string strEmpTSID) { //string strDay = null; //string strHrs = null; //Get the values stored in the text boxes string txtDivision = gvTaskNewRow[0].ToString(); string txtSegment = gvTaskNewRow[1].ToString(); string txtDetail = "0";//gvTaskNewRow[2].ToString(); string txtFuntion = "0";//gvTaskNewRow[3].ToString(); string txtDescription = "0";//gvTaskNewRow[4].ToString(); string txtTask = "0";//gvTaskNewRow[5].ToString(); string txtCounty = "0";//gvTaskNewRow[6].ToString(); string txtHighway = "0";//gvTaskNewRow[7].ToString(); //Get the values stored in the text boxes txtDivision = gvTaskNewRow[0].ToString(); txtSegment = gvTaskNewRow[1].ToString(); txtDetail = gvTaskNewRow[2].ToString(); txtFuntion = gvTaskNewRow[3].ToString(); txtDescription = gvTaskNewRow[4].ToString(); txtTask = gvTaskNewRow[5].ToString(); txtCounty = gvTaskNewRow[6].ToString(); txtHighway = gvTaskNewRow[7].ToString(); //Prepare the insert Command of the DataSource control (inserting new record into the TASK TABLE) string strInsertTask = ""; strInsertTask = "insert into TASK_WRK_ORDR_DTL (TXDOT_DIST_NBR,SGMNT_ID,DTL_CD,FUNC_CD,TASK_WRK_ORDR_CD,TXDOT_CNTY_NBR,HWY_CD,MISC_DSCR_TXT) valu