Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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];
            flbload.PostedFile.InputStream.Read(pic, 0, len);
            // Insert the image and comment into the database
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString =@"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
               
            try
            {
                connection.Open();
                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("@BillNo", SqlDbType.NVarChar).Value = TextBox1.Text;
                cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value = TextBox2.Text;
                cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox3.Text;
                cmd.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value = Rdbsdate.SelectedDate;
                cmd.Parameters.Add("@EndDate", SqlDbType.NVarChar).Value = Rdbddate.SelectedDate;
                cmd.Parameters.Add("@Systemurl", SqlDbType.Image).Value = pic;
                cmd.Parameters.Add("@Numberofcopies", SqlDbType.NVarChar).Value = TextBox7.Text;
                cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
                cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text;
                cmd.ExecuteNonQuery();
            }
            
            finally
            {
                connection.Close();
            }
        }
    }
}
My error image location not store
Posted
Comments
Sandeep Mewara 1-Apr-11 6:57am    
Not clear.

Kindly elaborate on what are you trying to do and what is the issue.
vimal22 2 2-Apr-11 4:28am    
i'm trying to store in a image and then record but i want store
image location path.
vimal22 2 2-Apr-11 4:31am    
i'm designing photo studio management system
so i have store customer details and then picture(only store picture location)
Sandeep Mewara 2-Apr-11 4:48am    
So what issue are you facing? Any error?
vimal22 2 2-Apr-11 5:39am    
No error but image location store in �က䙊䙉Āā䠀䠀 this type is it correct

1 solution

You try this 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=SSPI";
               
            try
            {
                connection.Open();
                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("@BillNo", SqlDbType.NVarChar).Value = TextBox1.Text;
                cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value = TextBox2.Text;
                cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox3.Text;
                cmd.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value = Rdbsdate.SelectedDate;
                cmd.Parameters.Add("@EndDate", SqlDbType.NVarChar).Value = Rdbddate.SelectedDate;
                cmd.Parameters.Add(new SqlParameter("@Systemurl",pic));
                cmd.Parameters.Add("@Numberofcopies", SqlDbType.NVarChar).Value = TextBox7.Text;
                cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
                cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text;
                cmd.ExecuteNonQuery();
            }
            
            finally
            {
                connection.Close();
            }
        }
    }
}


If above code not work then try this:
You try this 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";
               
            try
            {
                connection.Open();
                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));
                cmd.ExecuteNonQuery();
            }
            
            finally
            {
                connection.Close();
            }
        }
    }
}
 
Share this answer
 
v2
Comments
vimal22 2 2-Apr-11 5:08am    
@rkklalit11 thankyou but i had view the database but imagelocation of (Systemurl)table the small box and dot dot line display.
Is it correct
vimal22 2 2-Apr-11 5:15am    
this type of box are display �က䙊䙉Āā䠀䠀 is it correct

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



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