DETAILS VIEW ERRORS

Last post 05-17-2008 4:02 AM by geosync. 3 replies.

Sort Posts:

  • DETAILS VIEW ERRORS

    05-15-2008, 2:09 AM
    • Loading...
    • migs8teen
    • Joined on 05-09-2008, 5:14 AM
    • Posts 37

    "value cannot be null, parameter name:string"

    good day just want to ask if what's wrong with my code when im trying to build it there is no error by when i run the program it gives back an error i write in the top

    what is wrong with my code..

    all replies are truly appreciated.

    this is my code:

    using System;

    using System.Data;

    using System.Configuration;

    using System.Collections;

    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.OleDb;

    public partial class Details : System.Web.UI.Page

    {

    string stcron = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Database\\db1.mdb;Persist Security Info=False";

    System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection();

    System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter();

    System.Data.OleDb.OleDbCommand dc = new System.Data.OleDb.OleDbCommand();

    protected void Page_Load(object sender, EventArgs e)

    {

    AccessDataSource1.DataFile =
    ConfigurationSettings.AppSettings["dbLocation"].ToString();

    cn = new System.Data.OleDb.OleDbConnection(stcron);

    DataTable dt = new DataTable();

    int ID = Int32.Parse(Request.QueryString["rowID"]);

    AccessDataSource1.SelectCommand = "Select * from tblUser where id=" + ID + "";FormView1.DataSourceID = "AccessDataSource1";

     

     

     

    }

     

     

    protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)

    {

    TextBox Textbox1 = (TextBox)PreviousPage.FindControl("Textbox1");

    TextBox Textbox2 = (TextBox)PreviousPage.FindControl("Textbox2");

    TextBox Textbox3 = (TextBox)PreviousPage.FindControl("Textbox3");

    TextBox Textbox4 = (TextBox)PreviousPage.FindControl("Textbox4");

    TextBox Textbox5 = (TextBox)PreviousPage.FindControl("Textbox5");

    TextBox Textbox6 = (TextBox)PreviousPage.FindControl("Textbox6");

    TextBox Textbox7 = (TextBox)PreviousPage.FindControl("Textbox7");

    TextBox Textbox8 = (TextBox)PreviousPage.FindControl("Textbox8");

    TextBox Textbox9 = (TextBox)PreviousPage.FindControl("Textbox9");

    TextBox Textbox10 = (TextBox)PreviousPage.FindControl("Textbox10");

    TextBox Textbox11 = (TextBox)PreviousPage.FindControl("Textbox11");

    TextBox Textbox12 = (TextBox)PreviousPage.FindControl("Textbox12");

    TextBox Textbox13 = (TextBox)PreviousPage.FindControl("Textbox13");

     

    int rowID = Convert.ToInt32(e.Keys["ID"].ToString());if (Textbox1 != null)

    {

    cn.Open();

    dc = cn.CreateCommand();

    //string strQry = @"UPDATE tblUser Set (LastName,FirstName,MiddleName,Address,TelNo,CelNo,EmailAdd,Nationality,[Marital Status],Gender,Age,BirthPlace,BirthDate)" + "Values ('" + Textbox1.Text + "','" + Textbox2.Text + "','" + Textbox3.Text + "','" + Textbox4.Text + "','" + Textbox5.Text + "','" + Textbox6.Text + "','" + Textbox7.Text + "','" + Textbox8.Text + "','" + Textbox9.Text + "','" + Textbox10.Text + "','" + Textbox11.Text + "','" + Textbox12.Text + "','" + Textbox13.Text + "')";

    string strQry= @"UPDATE tblUser Set LastName= '"+Textbox1.Text+"', FirstName='"+Textbox2.Text+"',MiddleName='"+Textbox3.Text+"',Address='"+Textbox4.Text+"',TelNo="+Textbox5.Text+",CelNo="+Textbox6.Text+",EmailAdd='"+Textbox7.Text+"',Nationality='"+Textbox8.Text+"',[Marital Status]='"+Textbox9.Text+"',Gender='"+Textbox10.Text+"',Age="+Textbox11.Text+",BirthDate='"+Textbox12.Text+"',BirthPlace='"+Textbox13.Text+"'";

    dc.CommandText = strQry;

    dc.ExecuteNonQuery();

    cn.Close();

    }

    }

    }

    and also what is wrong with my itemUpdating code?

    why is it that i can't update??pls check..

    thanks to all

     

    -migs-

  • Re: DETAILS VIEW ERRORS

    05-15-2008, 2:41 AM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 4:44 PM
    • Boston, MA, USA
    • Posts 409

    migs8teen:
    "value cannot be null, parameter name:string"

    Where is this exception thrown?

    ~ Timing is Everything! ~
  • Re: DETAILS VIEW ERRORS

    05-15-2008, 2:55 AM
    • Loading...
    • migs8teen
    • Joined on 05-09-2008, 5:14 AM
    • Posts 37

     

    sir this is the code where the exeption is thrown

    int ID = Int32.Parse(Request.QueryString["rowID"]);

    pls help me sir..

    tnx in advance..

  • Re: DETAILS VIEW ERRORS

    05-17-2008, 4:02 AM
    Answer
    • Loading...
    • geosync
    • Joined on 03-26-2006, 4:44 PM
    • Boston, MA, USA
    • Posts 409

    I suggest testing for NULL first, like this:

    if (Request.QueryString["rowID"] != null)

    {

    int ID = Int32.Parse(Request.QueryString["rowID"]);

    }

    Of course, you may wish to throw an exception in case of NULL, depending on your situation.

    ~ Timing is Everything! ~
Page 1 of 1 (4 items)