Click here to Skip to main content
15,174,684 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have store image and then customer details but database table store in image location (path)but store image location is �က䙊䙉Āā䠀䠀 this type are stored is it correct? but no currect only store image location EXAMPLE (D:documentsetting\"k.jpeg) i want this type are store any change any code
namespace photoshops
    public partial class WebForm1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        protected void Button1_Click(object sender, EventArgs e)
            onflbload(sender, e);
           public void onflbload(object sender, EventArgs e)
            // Create a byte[] from the input file
            int len = flbload.PostedFile.ContentLength;
            byte[] pic = new byte[len+1];
            flbload.PostedFile.InputStream.Read(pic, 0, pic.Length);
            // Insert the image and comment into the database
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString =@"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=true";
                SqlCommand cmd = new SqlCommand("insert into tblphotosettings "
                 + "(BillNo,CustomerName,Address,StartDate,EndDate,Systemurl,Numberofcopies,Amount,Total ) values (@BillNo,@CustomerName,@Address,@StartDate,@EndDate,@Systemurl,@Numberofcopies,@Amount,@Total)", connection);
                cmd.Parameters.Add(new SqlParameter("@BillNo", TextBox1.Text));
                cmd.Parameters.Add(new SqlParameter("@CustomerName", TextBox2.Text));
                cmd.Parameters.Add(new SqlParameter("@Address", TextBox3.Text));
                cmd.Parameters.Add(new SqlParameter("@StartDate",Rdbsdate.SelectedDate));
                cmd.Parameters.Add(new SqlParameter("@EndDate", Rdbddate.SelectedDate));
                cmd.Parameters.Add(new SqlParameter("@Systemurl",pic));
                cmd.Parameters.Add(new SqlParameter("@Numberofcopies", TextBox7.Text));
                cmd.Parameters.Add(new SqlParameter("@Amount", TextBox8.Text));
                cmd.Parameters.Add(new SqlParameter("@Total", TextBox9.Text));
Updated 2-Apr-11 0:55am

1 solution

cmd.Parameters.Add(new SqlParameter("@Systemurl",pic));

You have passed pic as the parameter. Now check what pic contains -
byte[] pic = new byte[len+1];
flbload.PostedFile.InputStream.Read(pic, 0, pic.Length);

It contains your uploaded file. How do you expect it to contain the path of the stored image?

If you need to save the file to a disk and save it's path in the database, you first save the file in a sub-folder inside your web-application root folder. Then use MapPath function to get the relevant path on the server and save that path in the database.
There are so many examples available on the web. I want to search Google and give it a try! :thumbsup:
vimal22 2 2-Apr-11 6:56am
thank you how to change the code any idea send me because i m beginner
Ankur\m/ 2-Apr-11 6:59am
I do know, but I am watching India-SL world cup finals ;).
Being a beginner you should try hard to solve things, will help you in long run. I already told you how to do it and advised you to search Google for examples. Put some effort, please!
vimal22 2 2-Apr-11 7:09am
thank you ......i have search Google and if you have free time and then send me code thank you enjoy cricket
Ankur\m/ 2-Apr-11 7:20am
When people don't understand that we help here because we love doing so. And asking to send code is considered very rude. Why do I do your work? Do I get paid? You said you searched Google - did you not find anything? If your answer is NO, you haven't tried enough. Start searching with - "save file path in database". And try different combination, you will definitely find a solution. TRY!
vimal22 2 2-Apr-11 8:07am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900