473,773 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem: ds.Tables ["xx"].Columns ["xx"] always returns null

This is causing me to not be able to create a relation in my dataset.
Here's my code:

dc1 = ds.Tables ["categories "].Columns ["ID"];
dc2 = ds.Tables ["subcategor ies"].Columns ["Category_I D"];
dr1 = new System.Data.Dat aRelation ("categories2su bcategories", dc1,
dc2);
ds.Relations.Ad d (dr1);

dc1 always works fine. dc2 always returns null. There ARE records in
the dc2 table. Any idea why it's returning null?

I can't find any documentation anywhere about this. :(

Thanks in advance for any help.

-Brian
Nov 16 '05 #1
8 2371
Brian,

Are you saying that the value returned by the call to the indexer of the
object returned by the Columns property returns null? Or do you mean
something else?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian" <br*********@ky .gov> wrote in message
news:63******** *************** ***@posting.goo gle.com...
This is causing me to not be able to create a relation in my dataset.
Here's my code:

dc1 = ds.Tables ["categories "].Columns ["ID"];
dc2 = ds.Tables ["subcategor ies"].Columns ["Category_I D"];
dr1 = new System.Data.Dat aRelation ("categories2su bcategories", dc1,
dc2);
ds.Relations.Ad d (dr1);

dc1 always works fine. dc2 always returns null. There ARE records in
the dc2 table. Any idea why it's returning null?

I can't find any documentation anywhere about this. :(

Thanks in advance for any help.

-Brian

Nov 16 '05 #2
Hi Brian,
dc2 = ds.Tables ["subcategor ies"].Columns ["Category_I D"];
Is this the line with the "issue"
if it's so it;s because the column "Category_I D" does not exist in the
"subcategor ies" table. Check the definition of the table.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Brian" <br*********@ky .gov> wrote in message
news:63******** *************** ***@posting.goo gle.com... This is causing me to not be able to create a relation in my dataset.
Here's my code:

dc1 = ds.Tables ["categories "].Columns ["ID"];
dc2 = ds.Tables ["subcategor ies"].Columns ["Category_I D"];
dr1 = new System.Data.Dat aRelation ("categories2su bcategories", dc1,
dc2);
ds.Relations.Ad d (dr1);

dc1 always works fine. dc2 always returns null. There ARE records in
the dc2 table. Any idea why it's returning null?

I can't find any documentation anywhere about this. :(

Thanks in advance for any help.

-Brian

Nov 16 '05 #3
Hi, Ignacio. Yes, that's the line. The Category_ID field is definitely
in the (Access) table.

It's not a primary key, however. There aren't any rules saying
Category_ID must be the pk, are there? I can't figure out why this line
returns null...

--------------------
Hi Brian,
dc2 = ds.Tables ["subcategor ies"].Columns ["Category_I D"];


Is this the line with the "issue"
if it's so it;s because the column "Category_I D" does not exist in the
"subcategor ies" table. Check the definition of the table.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
Hi Brian,

It should be the PK in the category table, but that's not the problem
though.

if that line return null is cause the column is not found in the table, use
the watch to see if it does exist, check que query that you use to generate
the table, somewhere somehow you are not getting that column from the access
DB.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Brian Kiser" <br*********@ky .gov> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...
Hi, Ignacio. Yes, that's the line. The Category_ID field is definitely
in the (Access) table.

It's not a primary key, however. There aren't any rules saying
Category_ID must be the pk, are there? I can't figure out why this line
returns null...

--------------------
Hi Brian,
dc2 = ds.Tables ["subcategor ies"].Columns ["Category_I D"];


Is this the line with the "issue"
if it's so it;s because the column "Category_I D" does not exist in the
"subcategor ies" table. Check the definition of the table.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #5
I'll do some more tracing and try to pinpoint the problem further.

It can't be the pk because it's actually the fk to the Category table.
I'm trying to establish a relationship between the Categories and
Subcategories tables, and it's a 1-to-many relationship, so I can't use
the two pk's from each table.

The interesting thing is, if I substitute the REAL pk of Subcategories
in the statement, instead of "Category_I D", then I don't get any errors.
It doesn't work correctly, because the relationship must be
Categories.pk --> Subcategories.f k, but the statement returns something
other than null.

Weird.
---------------
Hi Brian,

It should be the PK in the category table, but that's not the problem
though.

if that line return null is cause the column is not found in the table,
use
the watch to see if it does exist, check que query that you use to
generate
the table, somewhere somehow you are not getting that column from the
access
DB.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6
Hi Brian,
It can't be the pk because it's actually the fk to the Category table.
That's what I meant, sorry for not specify it.

The interesting thing is, if I substitute the REAL pk of Subcategories
in the statement, instead of "Category_I D", then I don't get any errors.


Again, let's focus in your current problem, it's not a matter of
relationship, but it's that the column is not found in the Colums collection
of the table.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 16 '05 #7
Wahoo... I have that fixed now. You are the one that put me onto the
solution. I did have the field in my table, but because of a typo, it
wasn't getting into my dataset.

So thanks *very much* for that! I appreciate the help.

Now my problem is that the field is a foreign key to the Categories
table. Category.pk <-->> Subcategories.f k

So there's no way I can use Subcategories.p k for the relationship.
---------
Again, let's focus in your current problem, it's not a matter of
relationship, but it's that the column is not found in the Colums
collection
of the table.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #8
Hi ,
Now my problem is that the field is a foreign key to the Categories
table. Category.pk <-->> Subcategories.f k

So there's no way I can use Subcategories.p k for the relationship.


You don;t need it, just create the DataRelation between the two columns.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2531
by: Brian Maupin | last post by:
I have a refreshing webcam shot on my site and I was wondering if there was a way I could display how many people are currently viewing it? Thanks in advance.
20
18385
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've been doing something like delete from foo where name = 'xx'; insert into foo values('xx',1,2,...);
0
1092
by: Eric W | last post by:
I am converting an EXCEL VBA application to Visual Basic (2003). I am not having much luck finding how to convert statements containing references to things like ThisWorkbook.Sheets("sheetname"). I am not using Visual Studio Tools (which may be my problem, tho I would think that I don't really need the templates --- or do I??) Eric
4
4403
by: Eric W | last post by:
I am converting an EXCEL VBA application to Visual Basic (2003). I am not having much luck finding how to convert statements containing references to things like ThisWorkbook.Sheets("sheetname"). I am not using Visual Studio Tools (which may be my problem, tho I would think that I don't really need the templates --- or do I??) Eric
0
1437
by: Laurence | last post by:
Hi there, I cannot use "setup /i xx" to install DB2 Client (v9fp2_win_client.zip) on Win XP SP2. The installation process was stopped at the page "Select the languages to install". But use "setup" to install DB2 Client in defualt language is ok. Does anyone experience that?
0
1181
by: jaimebienlesfruits | last post by:
Is there a script I can include on the bottom of each page to indicate when the page was last updated? The PHP timstamp thing doesn't seem to work as it reflects the date of visit on the user's part. Thanks:D
1
2181
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns (LoginName,UserName) 2. the datagridview sorting is set to automatic, so when i click on the column header is sorts well. 3. i put in an event handler for the CellEndEdit Event, so whenever the user of the program changes the content of a cell in the LoginName...
4
1803
MrPickle
by: MrPickle | last post by:
What's the difference between the two? They both appear to do the same thing but if they both just did the same thing then why have 2 things to do 1 job?
15
3187
by: =?ISO-8859-15?Q?L=E9na=EFc?= Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, For some reasons, somewhere in a program, I'd like, if possible, to quickly parse a whole file before rewinding it and letting the full analysis start. My problem is that the FILE* I want do parse has been fopen'ed far away from where I am and I don't know in which MODE my FILE* has been opened. And additionally, my FILE* may not be a regular file, but a continuous
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.