Hello Everyone..!
this is your friend Md Aamir
so let's point to the problem is that bfeore image option data waz being inserted but then i using image option so data is not being inserted m i doing wrong plz give solution if i m
i will be your thankfull
here you go for my cs code:
- protected void btnbut_Click(object sender, EventArgs e)
- {
- if (imageupload.HasFile)
- {
- string strpath = System.IO.Path.GetExtension(imageupload.FileName);
- if (strpath != ".jpg" || strpath != ".jpeg" || strpath != ".gif" || strpath != ".png" || strpath != ".PNG" || strpath != ".GIF" || strpath != ".JPEG" || strpath != ".JPG")
- {
-
-
- }
- else
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("insert2", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@category", ddlcategory.SelectedValue);
- cmd.Parameters.AddWithValue("@name", txtname.Text);
- cmd.Parameters.AddWithValue("@color", txtcolor.Text);
- cmd.Parameters.AddWithValue("@price", txtprice.Text);
- string filename = DateTime.Now.Date.ToString("ddMMyyyy") + DateTime.Now.Minute + DateTime.Now.Millisecond + Path.GetExtension(imageupload.FileName);
- imageupload.SaveAs(Server.MapPath("~/Upload/") + filename);
- cmd.Parameters.AddWithValue("@Image1", filename);
- lblimgupl.Text = "Image successfully uploaded ";
- cmd.ExecuteNonQuery();
- con.Close();
- fill_grd();
- }
- }
- }
here aspx page: -