-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdation.aspx.cs
99 lines (83 loc) · 3.22 KB
/
Updation.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System;
using System.Web.UI.WebControls;
public partial class Updation : System.Web.UI.Page
{
String constr = "Data Source=omisbi3.niunt.niu.edu;Initial Catalog=Z1781921;Initial Catalog=Z1781921;User ID=z1781921;Password=Bw1243$h11";
protected void Page_Load(object sender, EventArgs e)
{
Update.Visible = false;
VehicleDetails.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(constr))
{
try
{
using (var cmd1 = new SqlCommand("insert into CityNames(CityName) values(@CityName)"))
{
conn.Open();
//cmd1.Parameters.AddWithValue("@CityID", count3);
cmd1.Parameters.AddWithValue("@CityName", TextBox1.Text);
cmd1.Connection = conn;
cmd1.ExecuteNonQuery();
Button1.Visible = false;
Update.Visible = true;
conn.Close();
}
}
catch (Exception E)
{
String s = E.Message;
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(constr))
{
try
{
using (var cmd1 = new SqlCommand("INSERT INTO [Vehicle] ([CarMake],[CarModel],[Color],[Seating],[Economy],[Price],[Availability]) VALUES(@Make,@Model,@Color,@Seating,@Economy,@Price,@Avail)"))
{
//cmd1.CommandText = "INSERT INTO [Vehicle] ([CarMake],[CarModel],[Color],[Seating],Economy],[Price],[Availability]) VALUES(@Make,@Model,@Color,@Seating,@Economy,@Price,@Avail)";
cmd1.Connection = conn;
cmd1.Parameters.AddWithValue("@Make", TextBox3.Text);
cmd1.Parameters.AddWithValue("@Model", TextBox4.Text);
cmd1.Parameters.AddWithValue("@Color", TextBox7.Text);
cmd1.Parameters.AddWithValue("@Seating", TextBox8.Text);
cmd1.Parameters.AddWithValue("@Economy", TextBox9.Text);
cmd1.Parameters.AddWithValue("@Price", TextBox5.Text);
cmd1.Parameters.AddWithValue("@Avail", TextBox6.Text);
//cmd1.Connection = conn1;
cmd1.ExecuteNonQuery();
//conn1.Close();
Button2.Visible = false;
VehicleDetails.Visible = true;
}
}
catch (Exception E)
{
String s = E.Message;
}
finally
{
if (conn != null)
{
conn.Close();
}
}
}
}
}