Problem I am having is when I want to insert into multiple columns at the same time.
What I had was:
AccessDataSource1.InsertCommand = "INSERT INTO [CoursesTaken] (StudentID) VALUES ('" TextBox1.Text + "');"; AccessDataSource1.Insert();AccessDataSource1.DataBind();
That inserts into one column but when I attempt this:
AccessDataSource1.InsertCommand = "INSERT INTO [CoursesTaken] (StudentID, CourseID) VALUES ('" + TextBox1.Text + "''" + TextBox2.Text + "');"; AccessDataSource1.Insert();AccessDataSource1.DataBind();
It gives me the error message "Number of query values and destination fields are not the same."
So then I attempted this:
if (e.CommandName.CompareTo("Insert") == 0)
{
int newIndex = Convert.ToInt32(e.CommandArgument);
AccessDataSource1.InsertCommand = "INSERT INTO [CoursesTaken] (StudentID, CourseID) VALUES ('" + TextBox1.Text + "''" + TextBox2.Text + "');";
AccessDataSource1.InsertParameters.Add(TextBox1.Text, GridView1.Rows[newIndex].Cells[0].Text);
AccessDataSource1.InsertParameters.Add(TextBox2.Text, GridView1.Rows[newIndex].Cells[1].Text);
AccessDataSource1.Insert();
AccessDataSource1.DataBind();
}
And it is still giving me the error message. Would anyone mind explaining this to me?