-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.aspx.cs
58 lines (40 loc) · 1.5 KB
/
contact.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Xml.Linq;
using System.Web.Security;
namespace projekti
{
public partial class contact : System.Web.UI.Page
{
SqlCommand cmd1 = new SqlCommand();
SqlConnection con2 = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
con2.ConnectionString = @"Data Source=DESKTOP-KHMSUE2\SQLEXPRESS;Initial Catalog=Projekt1DB;Integrated Security=True";
con2.Open();
}
protected void btnsignup_Click(object sender, EventArgs e)
{
try
{
SqlCommand cmd1 = new SqlCommand("insert into contact " + "(Email,Username,Reasons,Text)values(@Email,@Username,@Reasons,@Text)", con2);
cmd1.Parameters.AddWithValue("@Email", txtname.Text);
cmd1.Parameters.AddWithValue("@Username", txtusername1.Text);
cmd1.Parameters.AddWithValue("@Reasons", DropDownList1.SelectedItem.ToString());
cmd1.Parameters.AddWithValue("@Text", Txt.Text.ToString());
cmd1.ExecuteNonQuery();
Response.Redirect("WebForm1.aspx");
}
catch
{
Label7.Text = "You already submitet the from";
}
}
}
}