/// <summary> /// Inserts Icon into ICON table /// </summary> /// <param name="dbConnection"></param> /// <param name="dbQueries"></param> /// <param name="buffer"></param> /// <param name="iconType"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="elementType"></param> /// <param name="elementNid"></param> /// <returns></returns> public static int InsertIcon(DIConnection dbConnection, DIQueries dbQueries, byte[] buffer, string iconType, int width, int height, string elementType, string elementNid) { int RetVal = 0; //System.Data.OleDb.OleDbCommand cmd; //OleDbParameter prmPic = new OleDbParameter(); DbCommand Command = dbConnection.GetCurrentDBProvider().CreateCommand(); DbParameter Parameter; string SqlQuery = string.Empty; try { SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Icon.Insert.InsertIcon(dbQueries.DataPrefix, iconType, width, height, elementType, elementNid); //-- Change for Online Database SqlQuery = SqlQuery.Replace("?", "@Element_Icon"); //SqlQuery = dbQueries.FetchAndUpdateIcons(1, clsIcons.TableName, iconType, width, height, elementType, elementNid); // -- Get New NID generated //cmd = new OleDbCommand(SqlQuery, (OleDbConnection)dbConnection.GetConnection); //cmd.CommandType = CommandType.Text; Command.Connection = dbConnection.GetConnection(); Command.CommandText = SqlQuery; Command.CommandType = CommandType.Text; Parameter = dbConnection.GetCurrentDBProvider().CreateParameter(); { //prmPic.ParameterName = "@Element_Icon"; ////the name used in the query for the parameter //prmPic.OleDbType = OleDbType.Binary; ////set the database type //prmPic.Value = buffer; ////assign the contents of the buffer to the value of the parameter Parameter.ParameterName = "@Element_Icon"; //the name used in the query for the parameter Parameter.DbType = DbType.Binary; //set the database type Parameter.Value = buffer; //assign the contents of the buffer to the value of the parameter } //cmd.Parameters.Add(prmPic); Command.Parameters.Add(Parameter); //-- add the parameter to the command //cmd.ExecuteNonQuery(); Command.ExecuteNonQuery(); //-- this saves the image to the database RetVal = Convert.ToInt32(dbConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY")); } catch (Exception ex) { throw new ApplicationException(ex.Message); } finally { if ((Command != null)) { Command.Dispose(); } } return(RetVal); }