Connecting Tech Pros Worldwide Forums | Help | Site Map

Modify Table Using Code

Newbie
 
Join Date: Sep 2008
Posts: 7
#1: Sep 23 '08
Hi All,

I have a huge MS Access database in which requests are added at regular basis as in almost every minute.I have to modify the data type of one of the coloumns in this database,but i cant copy the database to my system and make this change and then put it back.So i want to make the changes through ASP code.I had written the following code to do the same but this is not working.

Expand|Select|Wrap|Line Numbers
  1. <%@Language=VBScript
  2. Dim conn,rs,sConnection
  3.     Set conn=Server.CreateObject("ADODB.Connection")
  4.     sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
  5.     "Data Source=" & Server.MapPath("../fpdb/taxireq.mdb") & ";" & _
  6.     "Persist Security Info=False"
  7.     conn.Open(sConnection)
  8.  
  9. conn.execute("ALTER TABLE Request_detail MODIFY Namecon Memo")
  10. response.write("done")
  11. conn.close
  12. %>
  13.  
In the above code i want to change the data type of column "Namecon" from Text to Memo type because text type has limitation of storing only 255 characters.

Please suggest some changes which would help me in making the required change

Thanks in advance!!

shweta123's Avatar
Expert
 
Join Date: Nov 2006
Location: India,Pune
Posts: 686
#2: Sep 23 '08

re: Modify Table Using Code


Hi,

In order to alter the table using code you have to make the following change in the query :

conn.execute("ALTER TABLE Request_detail alter column Namecon Memo")



Hope this helps.
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 930
#3: Sep 26 '08

re: Modify Table Using Code


Hi priyammaheshwari,

I wouldn't advise changing the structure of your database through code while it is live - this could lead to all sorts of knock on problems that would suddenly affect your live users.

Of course, you might have already done this and nothing happened but I'd suggest finding some time to down the live system and testing the effect of the changes after you've made them before putting it back up.

Just my two pence worth!

Dr B
Reply