Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Using tableadapters to enter data from Object properties. How do you enter a foreign key?

$
0
0

Hi,

I'm still on a learning curve with C# and am wondering about this problem. I am using a MySQL database connected to a C# project. I have set up Tableadapters to get the data I need from object properties using the .Insert method. However one of the arguments I need is the foriegn key.

How do I get the foriegn key information and enter it? I am unsure about how to go about this. I have several tables with foriegn keys in the MySQL database.

Here's my example code;

flightdbDataSetTableAdapters.cargoTableAdapter cargo_TableAdapter = new flightdbDataSetTableAdapters.cargoTableAdapter();

cargo_TableAdapter.Insert(
n_Cargo.Pk_c_Cargo,
n_Cargo.c_FName,
n_Cargo.c_LName,
n_Cargo.c_ReceivedBy,
n_Cargo.c_Desc,
n_Cargo.c_l,
n_Cargo.c_h,
n_Cargo.c_w,
n_Cargo.c_Desc,
n_Cargo.c_Special,
"XYZ123", //Wants the foreign key details from another table. How do I do that?
);

Thanks for any help guys


Viewing all articles
Browse latest Browse all 3509

Trending Articles