I am trying to insert some new threat into two tables at the same time. The sql statement when running within sql management studio, works like a charm. But when i try and do an aspx page, coding the sql statement in C# codebehind, it returns something like it can not insert empty.
I have tried different sql statements, yet nothing seems to work.

The original statements are as following:

```
DECLARE @BrugerNavn NVARCHAR(50) = 'Bent'
DECLARE @Besked NVARCHAR(MAX) = 'Bents besked'
DECLARE @TraadNavn NVARCHAR(50) = 'Bents tråd'
DECLARE @KategoriID INT = 1

INSERT INTO TraadTabel
VALUES (@TraadNavn, @KategoriID)

INSERT INTO Beskeder
VALUES (@Besked, SCOPE_IDENTITY(), @BrugerNavn)

```

My C# code is as following:

```
protected void btnSubmit_Click(object sender, EventArgs e)
{
    string BrugerNavn = txtBrugerNavn.Text;
    string TradNavn = txtTraadNavn.Text;
    string Besked = txtBesked.Text;
    int KategoriID = int.Parse(Request.QueryString["id"]);

    SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["SimpeltForumConnectionString"].ConnectionString);
    SqlCommand FirstLoad = new SqlCommand("INSERT INTO TraadTabel VALUES (@TradNavn, @KategoriID)", conn);
    //SqlCommand SecondLoad = new SqlCommand("INSERT INTO Beskeder VALUES (@Besked, SCOPE_IDENTITY(), @BrugerNavn)", conn);
    SqlCommand SecondLoad = new SqlCommand("INSERT INTO Beskeder VALUES (@Besked, SELECT IDENT_CURRENT(IndlaegID)+1, @BrugerNavn)", conn);

    FirstLoad.CommandType = CommandType.Text;
    FirstLoad.Parameters.AddWithValue("@TradNavn", TradNavn);
    FirstLoad.Parameters.AddWithValue("@KategoriID", KategoriID);
    SecondLoad.Parameters.AddWithValue("@Besked", Besked);
    SecondLoad.Parameters.AddWithValue("@BrugerNavn", BrugerNavn);

    using (conn)
    {
        conn.Open();
        FirstLoad.ExecuteNonQuery();
        SecondLoad.ExecuteNonQuery();
    }
}

```

As you can see, I have commented the "SCOPE\_IDENTITY()"-line out, and left it, as it is the code that actually works, when triggered from within sql management studio.
And I think that it is the scope identity, that returns the error in my browser.
I do not know what to do, please help. Thanks.