I have an mdb file (MS Access). I want to rename a table's column.
I tried this and no exception is thrown, nor it works.
How am I supposed to implement it?Code:try { string szMDBFilePath ="c:\\temp\\db1.mdb"; string password =""; this.m_oleDBConnection.Close(); strTable = "Tabella1"; strOldColumnName = "campo1"; strNewColumnName = "newcolname"; this.m_oleDBConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + szMDBFilePath + ";Jet OLEDB:Database Password=" + password + ";"; m_oleDBConnection.Open(); m_oleDBDataAdapter = new OleDbDataAdapter("SELECT * FROM [" + strTable + "]", m_oleDBConnection); m_DBDataSet = new DataSet(); this.m_oleDBDataAdapter.Fill(m_DBDataSet, "[" + strTable + "]"); System.Data.DataTableCollection dtcConnessioneATabella = m_DBDataSet.Tables; DataTable dtTabella = dtcConnessioneATabella["[" + strTable + "]"]; this.m_oleDBDataAdapter.FillSchema(dtTabella, SchemaType.Source);//m_DBDataSet, "[" + strTable + "]"); dtTabella.Columns[strOldColumnName].ColumnName = strNewColumnName; this.m_oleDBDataAdapter.Update(dtTabella); return NO_ERROR; } catch (Exception e) { m_strExceptionMessage = e.Message; return ERROR; }




Reply With Quote