4
Answers

Simple insert problem, C# + SQL

Ask a question
edu de souza

edu de souza

16y
2.6k
1
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)