473,287 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 ["subcategories"].Columns ["Category_ID"];
dr1 = new System.Data.DataRelation ("categories2subcategories", dc1,
dc2);
ds.Relations.Add (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 2333
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.com

"Brian" <br*********@ky.gov> wrote in message
news:63**************************@posting.google.c om...
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 ["subcategories"].Columns ["Category_ID"];
dr1 = new System.Data.DataRelation ("categories2subcategories", dc1,
dc2);
ds.Relations.Add (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 ["subcategories"].Columns ["Category_ID"];
Is this the line with the "issue"
if it's so it;s because the column "Category_ID" does not exist in the
"subcategories" 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.google.c om... 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 ["subcategories"].Columns ["Category_ID"];
dr1 = new System.Data.DataRelation ("categories2subcategories", dc1,
dc2);
ds.Relations.Add (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 ["subcategories"].Columns ["Category_ID"];


Is this the line with the "issue"
if it's so it;s because the column "Category_ID" does not exist in the
"subcategories" 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**************@TK2MSFTNGP12.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 ["subcategories"].Columns ["Category_ID"];


Is this the line with the "issue"
if it's so it;s because the column "Category_ID" does not exist in the
"subcategories" 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_ID", then I don't get any errors.
It doesn't work correctly, because the relationship must be
Categories.pk --> Subcategories.fk, 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_ID", 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.fk

So there's no way I can use Subcategories.pk 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.fk

So there's no way I can use Subcategories.pk 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
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
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...
0
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")....
4
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")....
0
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...
0
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....
1
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...
4
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
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...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.