locked
deployed app not inserting data into DB RRS feed

  • Question

  • Dear All,

    I have an application which if I run from VS 2005 runs perfectly and inserts data into Oracle table.

    But there is a deployed version of the same app(on the same machine) which does not insert data.

    Although the deployed app does not show any error now it does not insert the data in the database.

    The function where the problem exists i.e function is given below:

    public

     

    Int32 InsertIntoTable2(string connstring, string sql, DataTable dtb, ArrayList prmlist)

     

    Form1 ff = new Form1();

     

     

    // get rowcount of datatable

     

    // get column count of datatable

     

    // insert rows of datatable into Oracle table by invoking stored procedure

     

    string[] logmsgs = new string[2];

     

     

    string[] logmsgf = new string[2];

    logmsgs[0] =

     

    "submodule:InsertIntoTable1";

    logmsgs[1] =

     

    "Record inserted or updated successfully";

    logmsgf[0] =

     

    "submodule:InsertIntoTable1";

     

     

    int rcnt = dtb.Rows.Count;

     

     

    int ccnt = dtb.Columns.Count;

     

     

    ArrayList coldata = new ArrayList();

     

     

    ArrayList coldata1 = new ArrayList();

     

     

    if (connstring == string.Empty)

     

     

    MessageBox.Show("connstring Empty");

     

     

    if (sql == string.Empty)

     

     

    MessageBox.Show("sql Empty");

     

     

    if (dtb.Rows.Count <= 0)

     

     

    MessageBox.Show("dtb no rows");

     

     

    if (dtb == null)

     

     

    MessageBox.Show("dtb null");

     

     

    if (prmlist == null)

     

     

    MessageBox.Show("prmlist empty");

     

    //OracleString rownos;

     

    OracleConnection myconn = new OracleConnection(connstring);

     

     

    if (myconn != null)

     

     

    MessageBox.Show("Oracle connection succeeded");

     

     

    //string sql = "insert into Rehab_rules_area(\"exist_type_id\",\"new_type_id\",\"min_area\",\"max_area\",\"area_alloted\")values(" + mystr[0] + "," + mystr[1] + "," + mystr[2] + "," + mystr[3] + "," + mystr[4] + ")";

     

    Int32 res = 0;

     

     

    OracleCommand comm = new OracleCommand("", myconn);

    comm.CommandType =

     

    CommandType.StoredProcedure;

     

    // generate the parameters for the stored procedure

     

     

    //List<object> mylist = new List<object>();

     

    try

    {

     

    foreach (DataRow row in dtb.Rows)

     

    string prmdt = string.Empty;

     

     

    string[] prmdetails = new string[3];

     

     

    for (int k = 0; k < prmlist.Count; k++)

     

    Convert.ToString(prmlist[k]);

    prmdetails = prmdt.Split(

     

    ',');

     

     

    //string type = OracleDbType.

     

    OracleParameter oraparam = new OracleParameter();

     

    if (prmdetails[2] == "varchar2")

    oraparam.OracleDbType =

     

    OracleDbType.Varchar2;

     

     

    else if (prmdetails[2] == "number")

    oraparam.OracleDbType =

     

    OracleDbType.Int32;

     

     

    else if (prmdetails[2] == "Date")

    oraparam.OracleDbType =

     

    OracleDbType.Date;

     

     

    if (prmdetails[1] == "in")

    oraparam.Direction =

     

    ParameterDirection.Input;

     

     

    else if (prmdetails[1] == "out")

    oraparam.Direction =

     

    ParameterDirection.Output;

     

     

    else if (prmdetails[1] == "inout")

    oraparam.Direction =

     

    ParameterDirection.InputOutput;

     

     

    else if (prmdetails[1] == "return")

    oraparam.Direction =

     

    ParameterDirection.ReturnValue;

     

    if (prmdetails[1] == "in")

     

    ArrayList temp = new ArrayList();

     

     

    try

    {

     

    //coldata.Add(coldata1[k]);

     

    //for(int i=0;i<coldata1[k].

     

    //object[] p = coldata.ToArray(typeof(object)) as object[];

     

    //string[] dataarray = Array.ConvertAll<object, string>(p, new Converter<object, string>(ConvertIntToString));

     

    //dataarray = new string[rcnt];

     

    //dataarray = (string[])coldata.ToArray(typeof(string));

     

    //for (int m = 0; m < p.Length; m++)

     

    //{

     

    // string str = p[m].ToString() + ",";

     

    // if (m == coldata.Count - 1)

     

    // dataarray = str.Split(',');

     

    //}

     

    //(string[])coldata.ToArray(typeof(string));

     

    //int i = 0;

     

    //string[] mystr = new string[dtb.Rows.Count];

     

    //foreach (DataRow dr in dtb.Rows)

     

    //{ mystr[i] = dr[sr[k].ToString()].ToString(); i++;

     

    //}

    oraparam.Value = row[k].ToString();

     

    }

     

    catch (Exception ex)

     

    try

    {

     

    if (myconn.State == System.Data.ConnectionState.Closed)

     

    catch (Exception ex)

     

    //logmsgf[1] = ex.StackTrace;

     

    //ff.WriteToLog(iso, "CSVDBUpload/log/CSVDBUpload_log.txt", logmsgs);

    res = ex.GetHashCode();

     

    throw new Exception(ex.StackTrace, ex.InnerException);

     

     

    MessageBox.Show("InsertintoTable2" + ex.StackTrace);

     

    //Form1 ff = new Form1();

     

    //IsolatedStorageFile iso;

     

    //getLogdetails(out iso);

    }

     

    catch (Exception ex)

     

    "Failure to insert" + ex.StackTrace;

     

    //ff.WriteToLog(logmsgf);

    }

     

     

    myconn.Close();

    myconn.Dispose();

     

    //ff.WriteToLog(logmsgs);

     

    return res;

    }

    I am unable to find the problem.

    Could it be that it is not able to locate the server even with the conn string.

    Thanks for your efforts.

    res = ex.GetHashCode();

     

    {

    logmsgf[1] =

    }

    }

    res = 1;

     

     

     

     

    {

     

    myconn.Open();

    comm.ExecuteNonQuery();

    comm.Parameters.Clear();

    }

     

    {

    }

     

     

    }

    comm.Parameters.Add(oraparam);

     

    }

     

    {

     

     

     

    oraparam.ParameterName = prmdetails[0];

     

    {

    prmdt =

    {

     

    comm.CommandText = sql;

     

     

     

     

    {

     


    Today's knowledge is too little for tomorrow's job
    • Moved by eryang Friday, December 24, 2010 2:44 AM Move to ADO.NET forum foru better support. (From:.NET Base Class Library)
    Thursday, December 23, 2010 5:31 PM

Answers

  • My questions is:

    How do I program the setup program to ensure that things like .NET framework and other installables are installed prior to the install of my Assembly.

    Thanks.


    Today's knowledge is too little for tomorrow's job

    Hi sunny74,

    Thanks for your feedback.

    My bad link.

    You may repost your question here: http://social.msdn.microsoft.com/forums/en-US/winformssetup/threads/ where experts live in.

    Thanks for understanding.

    Have a nice day.

     


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jackie-Sun Monday, December 27, 2010 9:48 AM
    Monday, December 27, 2010 8:37 AM

All replies

  • Your did not show your query string. BTW, you may want to post to the ADO.Net forums under the Data Platform category since you are talking about ADO.Net classes.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Thursday, December 23, 2010 6:17 PM
  • Hi,

    query string ??

    Do u mean connection string?

    it is:

    Connection string: Data Source=orcltest;User ID=wonders_mumbai1;Password=mypassword


    Today's knowledge is too little for tomorrow's job
    Friday, December 24, 2010 5:54 AM
  • Command text, you can get it from the debugger

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, December 24, 2010 5:57 AM
  • Hi,

    I  have been able to narrow down and find the line which is failing.

    Earlier it was not giving any exception.

    So I put a try catch block around the myconn.open() line and is able to get the exception.

    The relevant code is:

    try

    {

     

    foreach (DataRow row in dtb.Rows)

    {

     

    string prmdt = string.Empty;

     

    string[] prmdetails = new string[3];

     

    for (int k = 0; k < prmlist.Count; k++)

    {

    prmdt =

    Convert.ToString(prmlist[k]);

    prmdetails = prmdt.Split(

    ',');

     

     

    OracleParameter oraparam = new OracleParameter();

    oraparam.ParameterName = prmdetails[0];

     

    if (prmdetails[2] == "varchar2")

    oraparam.OracleDbType =

    OracleDbType.Varchar2;

     

    else if (prmdetails[2] == "number")

    oraparam.OracleDbType =

    OracleDbType.Int32;

     

    else if (prmdetails[2] == "Date")

    oraparam.OracleDbType =

    OracleDbType.Date;

     

    if (prmdetails[1] == "in")

    oraparam.Direction =

    ParameterDirection.Input;

     

    else if (prmdetails[1] == "out")

    oraparam.Direction =

    ParameterDirection.Output;

     

    else if (prmdetails[1] == "inout")

    oraparam.Direction =

    ParameterDirection.InputOutput;

     

    else if (prmdetails[1] == "return")

    oraparam.Direction =

    ParameterDirection.ReturnValue;

     

     

    if (prmdetails[1] == "in")

    {

     

    ArrayList temp = new ArrayList();

     

    try

    {

     

    //coldata.Add(coldata1[k]);

     

    //for(int i=0;i<coldata1[k].

     

    //object[] p = coldata.ToArray(typeof(object)) as object[];

     

    //string[] dataarray = Array.ConvertAll<object, string>(p, new Converter<object, string>(ConvertIntToString));

     

    //dataarray = new string[rcnt];

     

    //dataarray = (string[])coldata.ToArray(typeof(string));

     

    //for (int m = 0; m < p.Length; m++)

     

    //{

     

    // string str = p[m].ToString() + ",";

     

    // if (m == coldata.Count - 1)

     

    // dataarray = str.Split(',');

     

    //}

     

    //(string[])coldata.ToArray(typeof(string));

     

    //int i = 0;

     

    //string[] mystr = new string[dtb.Rows.Count];

     

    //foreach (DataRow dr in dtb.Rows)

     

    //{ mystr[i] = dr[sr[k].ToString()].ToString(); i++;

     

    //}

    oraparam.Value = row[k].ToString();

     

    }

     

    catch (Exception ex)

    {

     

    MessageBox.Show(ex.Data.ToString());

    }

     

     

    }

    comm.Parameters.Add(oraparam);

     

    MessageBox.Show("parameter added");

     

    }

     

    try

    {

     

    MessageBox.Show("in 2nd try");

     

    //if (myconn.State == ConnectionState.Closed)

     

    try

    {

     

    MessageBox.Show("attempt to open conn");

    myconn.Open();

     

    MessageBox.Show("conn opened");

    }

     

    catch (Exception ex)

    {

     

    MessageBox.Show(ex.StackTrace);

     

    MessageBox.Show(ex.Message);

     

    MessageBox.Show(ex.Data.ToString());

     

    MessageBox.Show(ex.Source);

     

    MessageBox.Show(ex.InnerException.ToString());

    }

    comm.ExecuteNonQuery();

     

    MessageBox.Show("sp executed");

    comm.Parameters.Clear();

    myconn.Close();

    }

     

    catch (Exception ex)

    {

     

    //logmsgf[1] = ex.StackTrace;

     

    //ff.WriteToLog(iso, "CSVDBUpload/log/CSVDBUpload_log.txt", logmsgs);

    res = ex.GetHashCode();

     

    throw new Exception(ex.StackTrace, ex.InnerException);

     

    MessageBox.Show("InsertintoTable2" + ex.StackTrace);

    }

    }

    Now the exception is ORA-6413 connection not open.

    How to tackle it?


    Today's knowledge is too little for tomorrow's job
    Friday, December 24, 2010 10:11 AM
  • No idea, try forums.oracle.com. This isn't a Microsoft error.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, December 24, 2010 2:35 PM
  • No idea, try forums.oracle.com. This isn't a Microsoft error.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP


    Hi,

    Ok let me ask u some Microsoft related stuff which u must be knowing.

    My assembly is dependent on .NET framework 2.0 bec' it uses its classes.

    Now I have packaged .NET framework redistributable in the installer.

    So when the assembly gets installed I get to see the .net framework exe called dotnetfx.exe in the folder.

    But if my Assembly is installed on a machine where .NET is not present will it still work or do I have to configure the installer to check if the framework is installed and if not, install it first followed by the rest of it.

     

    Thanks.


    Today's knowledge is too little for tomorrow's job
    Friday, December 24, 2010 6:22 PM
  • That is usually done by the install software to make sure your target .Net version is present before your program is installed. It is called Prerequisite in Visual Studio Setup Projects, I am not sure how it is called in other MSI-authoring tools.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, December 24, 2010 8:50 PM
  • Hi,

    If I understood u correctly the .NET framework should be installed before my Assembly.

    Just mere presence of the framework exe in my Assembly folder will not work.

    So how to install the pre-requisites?

    Thanks.


    Today's knowledge is too little for tomorrow's job
    Saturday, December 25, 2010 3:39 PM
  • Hi sunny74,

    Welcome to MSDN forums.

    Please try to refer this link: http://www.c-sharpcorner.com/UploadFile/puranindia/699/

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 27, 2010 6:49 AM
  • Hi sunny74,

    Welcome to MSDN forums.

    Please try to refer this link: http://www.c-sharpcorner.com/UploadFile/puranindia/699/

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Hi,

    I have not asked u about connecting to Oracle using ODBC.

    My questions is:

    How do I program the setup program to ensure that things like .NET framework and other installables are installed prior to the install of my Assembly.

    Thanks.


    Today's knowledge is too little for tomorrow's job
    Monday, December 27, 2010 7:44 AM
  • My questions is:

    How do I program the setup program to ensure that things like .NET framework and other installables are installed prior to the install of my Assembly.

    Thanks.


    Today's knowledge is too little for tomorrow's job

    Hi sunny74,

    Thanks for your feedback.

    My bad link.

    You may repost your question here: http://social.msdn.microsoft.com/forums/en-US/winformssetup/threads/ where experts live in.

    Thanks for understanding.

    Have a nice day.

     


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jackie-Sun Monday, December 27, 2010 9:48 AM
    Monday, December 27, 2010 8:37 AM
  • Hi,

    Ok.I will post the question there.

    In the meantime can u solve this problem given in this link:

    http://social.msdn.microsoft.com/Forums/en/winforms/thread/a1c8a500-dda8-4b0c-af53-a85a52dd9be5

    Thanks


    Today's knowledge is too little for tomorrow's job
    Monday, December 27, 2010 9:02 AM