0
{ 
   string selectDesc = @" SELECT     [Descripion id], [Sub Collection FROM      Descripion   ";

    DataSet dsD = new DataSet();
    SqlCommand comD = new SqlCommand();
    comD.Connection = con;
    comD.CommandText = selectDesc;
    SqlDataAdapter daD = new SqlDataAdapter();
    daD.SelectCommand = comD;
    SqlCommandBuilder cbD = new SqlCommandBuilder(da);
    daD.Fill(dsD, "Descripion");
    DataRow new_row_Desc = dsD.Tables[0].NewRow();
    new_row_Desc["Descripion id"] = 58589;
    new_row_Desc["Sub Collection"] = TextBox18.Text;
            dsD.Tables[0].Rows.Add(new_row_Desc);
    daD.Update(dsD.Tables[0]);
}

I am getting this error:

Update requires a valid InsertCommand when passed DataRow collection with new rows.

What is the problem?

1
  • What language is this? What platform? It doesn't look like javascript. Commented Dec 8, 2010 at 11:44

1 Answer 1

2

First of all, your select statement is missing a closing "]" before FROM. Also, you're assigning a select command to the data adapter, but no insert and update commands. So the data adapter does not know what to do when inserting a new row.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.