SQL INSERT

    Date: 06/03/06 (C Sharp)    Keywords: sql, web

    I'm getting an error on my sql INSERT statement where I’ve bolded.
    I just want to update one field called subject, and it keeps giving errors during debug.
    Can anyone tell me what might be wrong?

    Also, without using stored procedures, is this a good safe way to do an INSERT?


    protected void Button1_Click(object sender, EventArgs e)
    {
    string conn = string.Empty;
    ConnectionStringsSection connectionStringsSection = WebConfigurationManager.GetSection("connectionStrings") as ConnectionStringsSection;
    if (connectionStringsSection != null)
    {
    ConnectionStringSettingsCollection connectStrings = connectionStringsSection.ConnectionStrings;
    ConnectionStringSettings connString = connectStrings["defaultConnectionString"];
    conn = connString.ConnectionString;

    using ( SqlConnection connection = new SqlConnection(conn))
    using (SqlCommand command = new SqlCommand("INSERT into POST (subject) VALUES (@subject)", connection))
    {
    connection.Open();
    command.ExecuteQuery();
    connection.Close();
    }
    }

    }

    Source: http://community.livejournal.com/csharp/64748.html

« Please help || dataset problem »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home