views:

127

answers:

0

Pretty basic question.

I have 2 tables: 1 stores contact info, 1 stores equipment lists. The equipment table has a contactID field that's FKed to the contact table.

I have a page that's used to add equipment, and when the user saves the new record I want to generate an email that has all the equipment info and some pertinent details about the contact.

So I have InsertCommand="insert into equipment [new values]; select [pertinent data] from contacts where id=@contact;" (contact is the FK. Below is my SQLDataSource definition:

<asp:SqlDataSource ID="SQL_Equipment" runat="server"
        InsertCommand="insert into equipment(company, make, model, otherDetails) values(@company, @make, @model, @otherDetails); select @name, @phone, @email from contacts where id = @company;"
        ConnectionString="<%$ ConnectionStrings:SecurityTutorialsConnectionString %>"
        OnInserted="SQL_Equipment_Inserted">

And the codebehind:

protected void SQL_Equipment_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
    if (e.Exception == null)
    {
        Response.Write(e.Command.Parameters["@name"].Value);
    }
    else
    {
        e.ExceptionHandled = true;
    }
}

Upon hitting Save the row is inserted properly, but the select appears not to run because all 3 returned parameters (name, fname, lname) are null when I view the Command.Parameters

Am I really going to have to create a whole other SQLDataSource just to get 3 fields??