Programming Practice

Posted by deepti on Stack Overflow See other posts from Stack Overflow or by deepti
Published on 2011-03-08T15:52:15Z Indexed on 2011/03/08 16:10 UTC
Read the original article Hit count: 138

Filed under:
 public DataTable UserUpdateTempSettings(int install_id, int install_map_id, string Setting_value,string LogFile)
    {

        SqlConnection oConnection = new SqlConnection(sConnectionString);
        DataSet oDataset = new DataSet();
        DataTable oDatatable = new DataTable();
        SqlDataAdapter MyDataAdapter = new SqlDataAdapter();

        try
        {
            oConnection.Open();
            cmd = new SqlCommand("SP_HOTDOC_PRINTTEMPLATE_PERMISSION", oConnection);            
            cmd.Parameters.Add(new SqlParameter ("@INSTALL_ID", install_id));
            cmd.Parameters.Add(new SqlParameter ("@INSTALL_MAP_ID", install_map_id));
            cmd.Parameters.Add(new SqlParameter("@SETTING_VALUE", Setting_value));
            if (LogFile != "")
            {
                cmd.Parameters.Add(new SqlParameter("@LOGFILE",LogFile));
            }
           cmd.CommandType = CommandType.StoredProcedure;
           MyDataAdapter.SelectCommand = cmd;
           cmd.ExecuteNonQuery();                    
           MyDataAdapter.Fill(oDataset);
           oDatatable = oDataset.Tables[0];
           return oDatatable;
        }
        catch (Exception ex)
        {
            Utils.ShowError(ex.Message);
            return oDatatable;
        }
        finally
        {
            if ((oConnection.State != ConnectionState.Closed) || (oConnection.State != ConnectionState.Broken))
            {
                oConnection.Close();
            }

            oDataset = null;
            oDatatable = null;
            oConnection.Dispose();
            oConnection = null;
        }
    }

i have used execute non query.. normally its not used with data adapter... if iam not using its giving me error.. is it bad programming practice to use execute non query with data adapter

© Stack Overflow or respective owner

Related posts about c#