By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

Renaming a field in access table

P: 1
i am renaming the field in access table but my module is sometime working sometime not working
1 Week Ago #1
Share this Question
Share on Google+
1 Reply

P: 94
It is how to changing the field name of mdb using and OleDb.
Expand|Select|Wrap|Line Numbers
  1.     Dim FileName As String = "your database path and filename"
  2.     Dim TableName As String     = "your table name"
  4.     Using cn As New System.Data.OleDb.OleDbConnection
  5.     Using cm As New System.Data.OleDb.OleDbCommand
  6.     Using da As New System.Data.OleDb.OleDbDataAdapter
  7.     'change your Connection String    
  8.     cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & FileName & ";"
  9.     cm.Connection = cn
  10.     'change your table modify SQL
  11.     cm.CommandText = "ALTER TABLE tbl_name RENAME COLUMN old_col_name TO new_col_name ... ;"
  12.     da.SelectCommand = cm
  13.     End Using
  14.     End Using
  15.     End Using
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.