Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Can't drop a relationship...

Author  Topic 

Santal_Maluko
Starting Member

14 Posts

Posted - 2005-01-03 : 04:51:23
I have a little prob here...

I have a relational databasee on ACCESS and I am trying to solve a little problem here...

I have a little program that picks the previous versions of the database and convert to the new format.... all is doing great except on little issue.

The last version of the program uses a database with the visitors and the respective company, in diferent tables. I use a key on the table visitors that is called "VisitorsCompany" and the data tipe is Number.

Now I am using a program in VC++ that modifies the database, adding some new fields, etc, etc...
But there is one cheange on the database that I can't do... That field VisitorsCompany is not a key anymore and is supposed to be from data type Text... I can't change the data type neither remove the relationship between this 2 tables...

I've tried DROP INDEX, DROP CONTRAINTS, and it was of no use... I can show you the code I used...

"strSQL ="DROP CONSTRAINT VisitorCompany ON Visitors";"

Diogo Alves

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-03 : 04:54:40
should be
drop index VisitorCompany ON Visitors

but I guess you tried that - what's the error?


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Santal_Maluko
Starting Member

14 Posts

Posted - 2005-01-03 : 05:18:27
well...

It does not give me any error it justs dont delete the relationship and don't alter the column data type.... if I go to the database after executing this code it shows me all the changes except that one, and if I try to modify in Access It says that cannot change it because I need to first delete the relationship, I am trying to do this for 2 days, and nothing... I'm getting desperated...

hope that someone can help me with this...

thanks for all the cooperation in advance.

Diogo Alves
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-03 : 05:30:46
Is this a foreign key?

it'll be

alter table Visitors drop constraint VisitorCompany

I think


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Santal_Maluko
Starting Member

14 Posts

Posted - 2005-01-03 : 06:03:17
When I use: "ALTER TABLE Visitors DROP CONSTRAINT VisitorCompany"
it gives this error, "CHECK constraint "VisitorCompany" does not exist."

and if I use: "ALTER TABLE Visitors DROP INDEX VisitorCompany" ,
it gives this error, "Syntax error in ALTER TABLE statement"

Diogo Alves
Go to Top of Page

Santal_Maluko
Starting Member

14 Posts

Posted - 2005-01-03 : 06:09:52
hey hey hey!!!! I got a progress here....
well, I opened the documenter of microsoft access, and saw the name of the indexes.....

The index that is related to the Companies table is VisitorsIx1
I did the drop index and it was sucessfull, but there still exists a relationship between the tables...

What can I do

Diogo Alves
Go to Top of Page

Santal_Maluko
Starting Member

14 Posts

Posted - 2005-01-03 : 06:14:33
I checked again the documenter and I found a index called Rel_000C1E06_C874_47E4 that is a foreign key...

maybe if I do a Drop Constraint here it will work...

I found were to see the errors, going by this way I should be able to fix this issue... and by the way thanks for the help you were giving me...


Diogo Alves
Go to Top of Page
   

- Advertisement -