-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreviewadd.aspx.cs
35 lines (32 loc) · 1.21 KB
/
reviewadd.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Policy;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebProject
{
public partial class WebForm4 : System.Web.UI.Page
{
string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void submit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO review ([name], [comments], [rating]) VALUES (@name, @comment, @rate)", con);
cmd.Parameters.AddWithValue("@name", rname.Text.Trim());
cmd.Parameters.AddWithValue("@comment", rcomment.Text.Trim());
cmd.Parameters.AddWithValue("@rate", rrating.Text.Trim());
cmd.ExecuteNonQuery();
Response.Write("<script>alert('Thank you for your review!');</script>");
Response.Redirect("~/home.aspx");
con.Close();
}
}
}