null reference exception not set to create an object instance
-
i 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
-
i 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
joynee wrote:
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) values (" + txtDivision + "," + txtSegment + "," + txtDetail + "," + txtFuntion + "," + txtTask + "," + txtCounty + "," + txtHighway + "," + txtDescription + ")";
Ah yes, string concatenation. Could someone please tell me what year it is? I'm sure I must have the wrong calendar. Dear joynee, you might want to do some research on something called "SQL injection".
-
joynee wrote:
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) values (" + txtDivision + "," + txtSegment + "," + txtDetail + "," + txtFuntion + "," + txtTask + "," + txtCounty + "," + txtHighway + "," + txtDescription + ")";
Ah yes, string concatenation. Could someone please tell me what year it is? I'm sure I must have the wrong calendar. Dear joynee, you might want to do some research on something called "SQL injection".
-
Well in 2008 if someone suggests you research something the obvious thing to do is type it into the Google keyword search input and click the search button. Then you attempt to locate a result that seems to provide a description of the item and read it. However I can see how that might seem counter intuitive to posting a question in a forum, wait, no actually I can't.
-
i 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
Ever heard about SQL Injection Attacks and Some Tips on How to Prevent Them[^] ? I guess no
Giorgi Dalakishvili #region signature my articles #endregion
-
i 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
Hi i found in your code , this code snippet //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(); please check is it correct? i think that should be like this //Get the values stored in the text boxes txtDivision.Text = gvTaskNewRow[0].ToString(); --- thanks
Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com
-
Hi i found in your code , this code snippet //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(); please check is it correct? i think that should be like this //Get the values stored in the text boxes txtDivision.Text = gvTaskNewRow[0].ToString(); --- thanks
Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com
No, his code is correct. You don't need to set the
.Text
property on a string. He prefixed the variables like it was a text box, but they were actually strings.I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer