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

  • Question

  • User-213201318 posted

    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

    Wednesday, September 18, 2013 11:37 PM

All replies

  • User-1454326058 posted

    Hi Pythonesque,

    Thanks for your post!

    Accroding to your description, I would like to know that is it a Windows Form application?

    If so, I sugget that you can consider to post it in Windows Form Forums for more efficient response.

    If not, Please provide the schema of your tables and the detail code.

    Thanks

    Best Regards

    Thursday, September 19, 2013 10:22 PM