edu de souza

edu de souza

  • NA
  • 65
  • 0

Simple insert problem, C# + SQL

Aug 12 2008 6:48 PM
Hi guys, I need a quick help. I´m trying to insert a int value but, comething went wrong ... I´m receiving this message:

System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value '@id_categoria' to data type int.
Code goes above:

<script runat="server">
//insert
void Insert_Click(Object Src, EventArgs E)
{
    SqlDataSource1.InsertParameters["id_categoria"].DefaultValue    = id_categoria.Text.ToString();
    SqlDataSource1.InsertParameters["acessorio"].DefaultValue       = acessorio.Text.ToString();
    SqlDataSource1.InsertParameters["codigo"].DefaultValue          = codigo.Text.ToString();
    SqlDataSource1.InsertParameters["tamanho"].DefaultValue         = tamanho.Text.ToString();
    SqlDataSource1.InsertParameters["texto"].DefaultValue           = texto.Text.ToString();
    SqlDataSource1.Insert();
    Response.Redirect("insert_ok.aspx");
}
</script>

Many thanks.

Answers (4)