Ciao

sto utilizzando un inserimento dati nel db con resize-img.

L'inserimento funziona perfettamente se utilizzo nel form due campi testo come "cognome" e "nome".

Se nella form inserisco anche una dropList che recupera i dati da TabCategoria per poi essere scritti in TabGiocatori, l'inserimento va sempre a BUON FINE, cioè scrive i valori del db e mi carica le immagini sul server, MA il db mi va in protezione creando un copia .ldb del database, ritrovando nella cartella questa situazione:

database.mdb
database.ldb

Perchè?


ATTENZIONE!

Nella DropList visualizzo i nomi della categoria ma poi nell'inserimento faccio scrivere in TabGiocatori sia il valore dell'id_categoria di TabCategoria in id_categoria e il nome della categoria nel campo nome_categoria di TabGiocatori, per capirci così:

TabCategoria --> TabGiocatori

nome --> nome_categoria
id_categoria --> id_categoria

Vi mostro il codice interessato:

Nel ASPX ho inserito la DropList e i due campi testo:

codice:
<asp:dropdownlist runat="server" id="DDLCategoria" AutoPostBack="true" />

<asp:TextBox id="cognome" Columns="30" runat="Server"/>

<asp:TextBox id="nome" Columns="30" runat="Server"/>
Nel CS il codice è questo:

codice:
 void Page_Load(object sender, System.EventArgs e)
  {
   Status.Text += "";
   
   string dbconn, sql, sql3, sql_lingua, dbcomm, dbread;
   OleDbConnection connDB;

   OleDbCommand cmd3; 
   OleDbDataReader aReader3;

   string connString = ConfigurationSettings.AppSettings["dbConnString"]; 
   connDB = new OleDbConnection(connString);
   connDB.Open();
   
  sql3 = "SELECT * FROM TabCategoria ORDER BY NOME asc";// WHERE NOME = CODICE_SUPER_CATEGORIA ORDER BY NOME asc";
  cmd3 = new OleDbCommand(sql3, connDB);
  aReader3 = cmd3.ExecuteReader();

  if (!Page.IsPostBack)
  {
	 DDLCategoria.DataTextField = "nome";
	 DDLCategoria.DataValueField = "id_categoria";
	 DDLCategoria.DataSource = aReader3;
	 DDLCategoria.DataBind();

	}

  {
    aReader3.Close();
  }

    //Chiudo la connessione
	connDB.Close();
   }  
  
  } // void Page_Load(object sender, System.EventArgs e)

codice:
void InserisciNomiDeiFilesNelDB_Access(string fileList, char token, string cognome, string nome, string nome_categoria, string id_categoria)

   string connString = ConfigurationSettings.AppSettings["dbConnString"];
   string imgFields = "";
   string imgValues = "";
   int ii = 0;
    
   foreach (string s in fileListSplitted) 
    { 
     if (s != "") 
      { 
	   ii++;
	   imgFields+="IMG_"+ii.ToString()+",IMG_TBN_"+ii.ToString()+",";
	   imgValues+="'" + (imgDestFolder() + s) + "','" + (tbnDestFolder() + s) + "',";
      } 
    } 
	
	string sqlString = "INSERT INTO [TabGiocatore] ("+imgFields+" COGNOME, NOME, NOME_CATEGORIA, ID_CATEGORIA) VALUES ("+imgValues+" '" + cognome + "', '" + nome + "', '" + nome_categoria + "', " + id_categoria + ");";

  string COGNOME = ""; 
  if ( (cognome.Text != "") && ((cognome.Text.ToString()).Length > 0) ) COGNOME = cognome.Text;
  
  string NOME = ""; 
  if ( (nome.Text != "") && ((nome.Text.ToString()).Length > 0) ) NOME = nome.Text;
  
  string NOME_CATEGORIA = "";
  if ( (DDLCategoria.SelectedItem.Text != "") && ((DDLCategoria.SelectedItem.Text.ToString()).Length > 0) ) NOME_CATEGORIA =DDLCategoria.SelectedItem.Text;
  NOME_CATEGORIA = NOME_CATEGORIA.Replace("'","''");
  
  string ID_CATEGORIA = ""; 
  if ( (DDLCategoria.SelectedItem.Text != "") && ((DDLCategoria.SelectedItem.Text.ToString()).Length > 0) ) ID_CATEGORIA = DDLCategoria.SelectedItem.Value;

codice:
   InserisciNomiDeiFilesNelDB_Access(ListaNomi, '|', COGNOME, NOME, NOME_CATEGORIA, ID_CATEGORIA);

  string COGNOME = ".";
  string NOME = ".";
  string NOME_CATEGORIA = ".";
  string ID_CATEGORIA = "";

  if ( (cognome.Text != "") && ((cognome.Text.ToString()).Length > 0) ) COGNOME = cognome.Text;
	
  if ( (nome.Text != "") && ((nome.Text.ToString()).Length > 0) ) NOME = nome.Text;
   
  if ( (DDLCategoria.SelectedItem.Text != "") && ((DDLCategoria.SelectedItem.Text.ToString()).Length > 0) ) NOME_CATEGORIA = DDLCategoria.SelectedItem.Text; //valore di nome_categoria

  if ( (DDLCategoria.SelectedItem.Text != "") && ((DDLCategoria.SelectedItem.Text.ToString()).Length > 0) ) ID_CATEGORIA = DDLCategoria.SelectedItem.Value; // valore di id_categoria

  InserisciNomiDeiFilesNelDB_Access(ListaNomi, '|', COGNOME, NOME, NOME_CATEGORIA, ID_CATEGORIA);
...spero qlc capisca!