I have this programming code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:IngBergConnectionString1 %>" 
            InsertCommand="INSERT INTO Table1(namn, development, roll, musik) VALUES (@namn,@development,@roll,@musik)" >
            <InsertParameters>
                <asp:Parameter Name="namn" Type="String" />
                <asp:Parameter Name="development" Type="String" />
                <asp:Parameter Name="roll" Type="String" />
                <asp:Parameter Name="musik" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>

But I can't connect up TextBoxes with Parameters. Which could be solution to this situation?
Thanks.

I have this programming code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:IngBergConnectionString1 %>" 
            InsertCommand="INSERT INTO Table1(namn, development, roll, musik) VALUES (@namn,@development,@roll,@musik)" >
            <InsertParameters>
                <asp:Parameter Name="namn" Type="String" />
                <asp:Parameter Name="development" Type="String" />
                <asp:Parameter Name="roll" Type="String" />
                <asp:Parameter Name="musik" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>

But I can't connect up TextBoxes with Parameters. Which could be solution to this situation?
Thanks.

Solution is

protected void Button1_Click(object sender, EventArgs e)
{
    using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"))
    {
        SqlCommand CmdSql = new SqlCommand("INSERT INTO [Movies] (ID, Name, Genre, Length, Year, Description) VALUES (@ID, @Name, @Genre, @Length, @Year, @Description)", conn);
        conn.Open();
        CmdSql.Parameters.AddWithValue("@ID", TextBox1.Text);
        CmdSql.Parameters.AddWithValue("@Name", TextBox2.Text);
        CmdSql.Parameters.AddWithValue("@Genre", TextBox3.Text);
        CmdSql.Parameters.AddWithValue("@Length", TextBox4.Text);
        CmdSql.Parameters.AddWithValue("@Year", TextBox5.Text);
        CmdSql.Parameters.AddWithValue("@Description", TextBox6.Text);
        CmdSql.ExecuteNonQuery();
        conn.Close();
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.