We help IT Professionals succeed at work.
Get Started

Insert, Update into SQL using DataAdapter and Textbox

Mapy123
Mapy123 asked
on
659 Views
Last Modified: 2013-12-17

Please help me, I am geting this error message:

"Insertion error: the column name or the specific values do not correspond to table definition"

I have some textboxs, what I am trying to do is to take the text the user is typing into my textboxs and insert it into my table, also I have to give the user the option to do "update", please help me, I am having bad time....

The UserID and Titulo columns are VarChar.

This is my code:

    protected void ButtonGuardaCurriculo_Click(object sender, EventArgs e)
    {
        string conString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\empleo.mdf;Integrated Security=True;User Instance=True";
        SqlConnection myConn = new SqlConnection(conString);
        SqlDataAdapter da = new SqlDataAdapter();
        da.InsertCommand = new SqlCommand("INSERT INTO Curriculo VALUES(@UserID, @Titulo)", myConn);
        da.InsertCommand.Parameters.Add("@UserID", SqlDbType.VarChar).Value = (String)Session["CurrentUser"];
        da.InsertCommand.Parameters.Add("@Titulo", SqlDbType.VarChar).Value = TextTitulo.Text;
        myConn.Open();
        da.InsertCommand.ExecuteNonQuery();
        myConn.Close();
        da.Dispose();
    }
Comment
Watch Question
C# ASP.NET Developer
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE