Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

No record is created

$
0
0
Hi,
I am to save one record to an Access table in one Console application having this

using System;
using System.IO;
... namespace File_upload { class Program { static byte[] ImageToStream(string fileName) { Bitmap image = new Bitmap(fileName);            ...

} static void Main(string[] args) { OleDbConnection conn = null; string fl_nm; OleDbCommand cmd;             ... { fl_nm = "z:\\ID-10033196.jpg"; cmd = new OleDbCommand("insert into prt_display (mod_name,photo_file) values ('Search_Auto',@image)", conn); cmd.Parameters.Add("@image", OleDbType.Binary).Value = ImageToStream(fl_nm); if (cmd.ExecuteNonQuery() >= 1) { Console.WriteLine("Record with the image has been saved."); } else Console.WriteLine("Record is not Saved."); } catch (SqlException ex) { Console.WriteLine("ex 1 "); } catch (Exception ex) { Console.WriteLine("ex 2 "); } finally { conn.Close(); } } } }



but when running the project. I get no message and no record has been created. why?

Many Thanks & Best Regards, Hua Min






Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>