-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdd Dummy Product.aspx.vb
33 lines (30 loc) · 1.25 KB
/
Add Dummy Product.aspx.vb
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
Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString)
Dim cmd As SqlCommand
Dim ad As SqlDataAdapter
Dim ds As New DataSet
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'FOR INSERTING ALL INFORMATION TO PRODUCT TABLE.
Dim path As String
path = Server.MapPath("Images/")
path = path + FileUpload1.FileName
FileUpload1.SaveAs(path)
path = "Images/" + FileUpload1.PostedFile.FileName
'STORE IMAGE IN FOLLOWING FORMAT. "FOLDERNAME/IMAGENAME.EXTENTsION.
cmd = New SqlCommand("insert into products values(@nm,@desc,@price,@img)", con)
cmd.Parameters.AddWithValue("@img", path)
cmd.Parameters.AddWithValue("@nm", TextBox1.Text)
cmd.Parameters.AddWithValue("@desc", TextBox2.Text)
cmd.Parameters.AddWithValue("@price", TextBox3.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Response.Write("added")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
End Class