-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebForm4.aspx.cs
33 lines (30 loc) · 1.38 KB
/
WebForm4.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
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;
namespace WebDevApplication3._0
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection addProd = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\WebsiteDevApplication\\WebDevApplication3.0\\App_Data\\Products.mdf;Integrated Security=True");
if (FileUpload1.HasFile)
{
string strname = FileUpload1.FileName.ToString();
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/upload/") + strname);
string uploadData = "Insert into Products values('" + strname + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "')";
SqlCommand uploadData1 = new SqlCommand(uploadData, addProd);
addProd.Open();
uploadData1.ExecuteNonQuery();
addProd.Close();
}
}
}
}