Link to home
Start Free TrialLog in
Avatar of ArunVashist
ArunVashistFlag for India

asked on

visual C#, MS-Access table alteration

Hi Friends,

I have a windows application developed in VS 2008 using C# and MS-Access as backend. Now this application is running perfectly, but due to some updates I need to add new columns in existing database tables, but as this application is being used by many of our clients for about 1-2 month and contains sensitive data which few of our client are not willing to share, so we are not able to physical add these columns into tables. So, we want  to provide them some Patch/update which just add new columns in Database.

Please help.

thanks in advance
Avatar of Yadtrt
Yadtrt
Flag of Iraq image

if you dont want to add that columns to the table, you can create new table with required columns and join it to the main table as one - one relationship.

Avatar of ArunVashist

ASKER

Hi Yadtrt,

Thanks for the quick reply but i think I could't make my self clear in post. well to Add columns we can ask them for the database and add the columns and sent them back, but they are not providing us the access to database, So we need a way out to run Alter Table queries at client end.

1. we will create a list of columns need to add into tables
2. we will create Sql queries to alter table (to add new columns.)
3. Now i want to run these sql queries at client end.

please suggest me a way out.
You can use DAO to add fields to the table.
Function AddFields()
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    
    'Initialize
    Set db = CurrentDb() '<===== You may need to change this if you want to work on remote database 
 
    Set tdf = db.TableDefs("TableName")
    
    'Add a field to the table.
    tdf.Fields.Append tdf.CreateField("Field1", dbText, 50)
    Debug.Print "Field added."
    
    Set fld = Nothing
    Set tdf = Nothing
    Set db = Nothing
End Function

Open in new window

also you can use ADO.net for altering the table, check this

http://msdn.microsoft.com/en-us/library/ms971485.aspx
Hi Yadtrt,

Its a Windows application written in C# using vS 2008 and data layer is using ADO.net, given sample code and link add almost nothing to solve this issue.
ASKER CERTIFIED SOLUTION
Avatar of Rahul Goel
Rahul Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial