<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:Conn %>'InsertCommand="INSERT INTO [TableName] ([s1], [s2]) VALUES (@s1, @s2)" >
<InsertParameters>
<asp:QueryStringParameter Name="s1" Type="Int16"></asp:Parameter>
<asp:QueryStringParameter Name="s2" Type="Int16"></asp:Parameter>
</InsertParameters>
</asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource1.Insert();
// Redirect
}
How to enter data into SQL Server using asp.net query string? [closed]
-
30-06-2022 - |
Question
Guys I need to store data into a SQL Server database using a querysting. I want to store the data if someone changes URL and post that url back to server.
e.g.
www.example.com/Default.aspx?s1=123&s2=456
By pressing enter I want to store the value of s1
and s2
into SQL Server database.
How do I do it?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow