Insert in two tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smurfas
    New Member
    • Jul 2008
    • 30

    Insert in two tables

    Hi, i Write in two table (HelpDesk nad HelpDesk2) + use Stored Procedure(Inser tHelpDesk and InsertHelpDesk2 )

    In first table (HelpDesk) don't insert record. Why?

    in second (HelpDesk2) all ok. All record insert.

    //--------Write to firs table, HelpDesk

    SqlConnection conn;
    SqlCommand comm;

    string connectionStrin g = ConfigurationMa nager.Connectio nStrings[
    "Dorknozzle "].ConnectionStri ng;
    // Initialize connection
    conn = new SqlConnection(c onnectionString );
    // Create command
    comm = new SqlCommand("Ins ertHelpDesk", conn);
    // Specify we're calling a stored procedure
    comm.CommandTyp e = System.Data.Com mandType.Stored Procedure;
    // Add command parameters
    comm.Parameters .Add("@Employee ID", System.Data.Sql DbType.Int);
    comm.Parameters["@EmployeeI D"].Value = 99999990;

    comm.Parameters .Add("@StationN umber", System.Data.Sql DbType.Int);
    comm.Parameters["@StationNumber "].Value = "9999990";

    comm.Parameters .Add("@Category ID", System.Data.Sql DbType.Int);
    comm.Parameters["@CategoryI D"].Value = "99999990";

    comm.Parameters .Add("@Descript ion", System.Data.Sql DbType.Int);
    comm.Parameters["@Descripti on"].Value = "9999999990 ";

    //--------Write to second table, HelpDesk2
    comm = new SqlCommand("Ins ertHelpDesk2", conn);
    // Specify we're calling a stored procedure
    comm.CommandTyp e = System.Data.Com mandType.Stored Procedure;
    // Add command parameters
    comm.Parameters .Add("@StatusID ", System.Data.Sql DbType.Int);
    comm.Parameters["@StatusID"].Value = 999990;

    comm.Parameters .Add("@SubjectI D", System.Data.Sql DbType.Int);
    comm.Parameters["@SubjectID "].Value = "99999990";

    ..........
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    At which points are you calling the ExecuteNonQuery () (or similar) for the updates to take place?

    Comment

    Working...