471,317 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Tables.CanRemove

I'm doing this:

if ((this.Tables.Contains(dt.TableName)) & (this.Tables.CanRemove(dt)))
{
this.Tables.Remove(dt);
}

and my table is not being removed. Which is fine, I guess. The things
is, I don't know why.

I have confirmed that it is the second portion of the boolean that's
saying no to my request (and, yes, the first portion is returning true).

So what are the possible reasons for CanRemove returning false? By what
criteria does its algorithm evaluate the question?
Nov 28 '05 #1
4 1183
C Glenn,

It's possible that there are constraints on a column which depend on a
column in the table you are trying to remove. You would have to remove
these constraints first, and then you could remove the table.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"C Glenn" <no****@domain.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm doing this:

if ((this.Tables.Contains(dt.TableName)) & (this.Tables.CanRemove(dt)))
{
this.Tables.Remove(dt);
}

and my table is not being removed. Which is fine, I guess. The things
is, I don't know why.

I have confirmed that it is the second portion of the boolean that's
saying no to my request (and, yes, the first portion is returning true).

So what are the possible reasons for CanRemove returning false? By what
criteria does its algorithm evaluate the question?

Nov 28 '05 #2
Just to make sure - you did actually use '&&' and not '&' in your code
right?
if ((this.Tables.Contains(dt.TableName)) & (this.Tables.CanRemove(dt)))
{
this.Tables.Remove(dt);
}
--
Adam Clauss

"C Glenn" <no****@domain.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... I'm doing this:

if ((this.Tables.Contains(dt.TableName)) & (this.Tables.CanRemove(dt)))
{
this.Tables.Remove(dt);
}

and my table is not being removed. Which is fine, I guess. The things
is, I don't know why.

I have confirmed that it is the second portion of the boolean that's
saying no to my request (and, yes, the first portion is returning true).

So what are the possible reasons for CanRemove returning false? By what
criteria does its algorithm evaluate the question?

Nov 28 '05 #3
No! I used '&'. Thanks for the tip. I looked up '&&' and will use it
in situations like this in future.

Adam Clauss wrote:
Just to make sure - you did actually use '&&' and not '&' in your code
right?

if ((this.Tables.Contains(dt.TableName)) & (this.Tables.CanRemove(dt)))
{
this.Tables.Remove(dt);
}


Nov 28 '05 #4
Absolutely no constraints of any kind.
Nicholas Paldino [.NET/C# MVP] wrote:
C Glenn,

It's possible that there are constraints on a column which depend on a
column in the table you are trying to remove. You would have to remove
these constraints first, and then you could remove the table.

Hope this helps.

Nov 28 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

44 posts views Thread by Mariusz Jedrzejewski | last post: by
3 posts views Thread by Random Person | last post: by
11 posts views Thread by dskillingstad | last post: by
59 posts views Thread by phil-news-nospam | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.