-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBikeForm.aspx.cs
65 lines (55 loc) · 1.72 KB
/
BikeForm.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
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace BikeRent
{
public partial class BikeForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SaveData()
{
SqlConnection conn = new SqlConnection();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
try
{
string connString = "Data Source=DESKTOP-H4VJE8D;Initial Catalog =BikeData;User Id=sa;Password=start";
string query = "insert into BikeListings(Name,Brand, Rent, ImageUrl) values ('"+name.Value+"','" + brand.Value + "','" + rent.Value + "','" + myfile.Value + "')";
conn = new SqlConnection(connString);
cmd = new SqlCommand(query, conn);
//cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
int m = cmd.ExecuteNonQuery();
if (m != 0)
{
Response.Write("<script>alert('Data Inserted')</script>");
}
else
{
}
}
catch (Exception ex)
{
}
finally
{
conn.Close();
conn.Dispose();
da.Dispose();
}
}
protected void btnSaveClick(object sender, EventArgs e)
{
SaveData();
}
}
}