تبلیغات
اطلاعات و فناوری های روز کامپیوتر - کد ارسال عکس به دیتابیس (ذخیره عکس در دیتابیس)
 
اطلاعات و فناوری های روز کامپیوتر
درباره وبلاگ



مدیر وبلاگ : توحید ابراهیمی
آمار وبلاگ
  • کل بازدید :
  • بازدید امروز :
  • بازدید دیروز :
  • بازدید این ماه :
  • بازدید ماه قبل :
  • تعداد نویسندگان :
  • تعداد کل پست ها :
  • آخرین بازدید :
  • آخرین بروز رسانی :
کد ارسال عکس به دیتابیس (ذخیره عکس در دیتابیس)

کد در ادامه مطلب
try
            {
                MemoryStream ms = new MemoryStream();
                pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
                byte[] arrImage = ms.GetBuffer();
                ms.Close();

                SqlConnection con = new SqlConnection("server=(local);trusted_connection=yes;database=DbName;");
                string strSQL = "INSERT INTO TabeName (filename,pic,id) VALUES ( @filename, @pic,@id)";
                SqlCommand cmd = new SqlCommand(strSQL, con);

                cmd.Parameters.Add(new SqlParameter("@filename", SqlDbType.Char, 50)).Value = textBox2.Text;//filename
                cmd.Parameters.Add(new SqlParameter("@pic", SqlDbType.Binary)).Value = arrImage;//picture
                cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Char, 50)).Value = textBox3.Text;//id
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();

                MessageBox.Show("Insert completed seccessfully.");;
            }
            catch (Exception ex)
            {
          MessageBox.Show(ex.Message       
;(

            }
      




نوع مطلب :
برچسب ها :
لینک های مرتبط :

       نظرات
جمعه 6 خرداد 1390
توحید ابراهیمی
سه شنبه 28 شهریور 1396 04:14 ق.ظ
Have you ever considered writing an ebook or guest authoring on other
websites? I have a blog based on the same subjects you discuss and would love to have you share some stories/information. I know my viewers would enjoy your work.
If you are even remotely interested, feel free to send me an e-mail.
دوشنبه 27 شهریور 1396 06:39 ق.ظ
I don't know if it's just me or if everyone else experiencing issues with your website.
It appears like some of the written text on your posts are
running off the screen. Can somebody else please comment and let me know
if this is happening to them too? This could be a issue with my internet browser
because I've had this happen before. Thank you
سه شنبه 14 شهریور 1396 02:43 ب.ظ
I'm really enjoying the design and layout of your blog.
It's a very easy on the eyes which makes it much more pleasant for me to come
here and visit more often. Did you hire out a developer to create your
theme? Excellent work!
سه شنبه 6 تیر 1396 06:44 ق.ظ
Exactly what I was searching for, regards for posting.
دوشنبه 5 تیر 1396 02:08 ب.ظ
Sweet blog! I found it while browsing on Yahoo News.
Do you have any suggestions on how to get listed in Yahoo News?
I've been trying for a while but I never seem to get there!
Appreciate it
پنجشنبه 21 اردیبهشت 1396 11:01 ب.ظ
This is very interesting, You're a very skilled blogger.
I have joined your rss feed and look forward to seeking
more of your fantastic post. Also, I have shared your web site in my social networks!
چهارشنبه 30 فروردین 1396 09:23 ب.ظ
Today, I went to the beachfront with my kids.
I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed the shell to her ear and screamed.

There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this is entirely off topic
but I had to tell someone!
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر