By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,497 Members | 1,295 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,497 IT Pros & Developers. It's quick & easy. save image in database

P: 15
In my project of desktop application using save image in database during registration of student But it is not mandatory.Without Browse the image i click on insert button it gives error "Empty path name is not legal".

Expand|Select|Wrap|Line Numbers
  1. con.ConnectionString = "Data Source=XPO3;Initial Catalog=Imsapplication;Integrated Security=True";
  2.            con.Open();
  3.            //Cryclass cc = new Cryclass();
  4.            string filepath = textBox2.Text;
  5.            FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
  6.            BinaryReader br = new BinaryReader(fs);
  7.            byte[] photo = br.ReadBytes((int)fs.Length);
  10.            br.Close();
  11.            fs.Close();
How to resolve it using NullReferenceException
Jul 12 '08 #1
Share this Question
Share on Google+
1 Reply

P: 50
hi ranjana,
i got the code in 2003 , it is working fine .

imgstyle is Picture Box

Dim msImage As New MemoryStream
dim strSQL as string

imgStyle.Image.Save(msImage, imgStyle.Image.RawFormat)

Dim arrImage() As Byte = msImage.GetBuffer
dim cmd as sqlcommand

strSQL = "INSERT INTO tblDesignDetails (imgDesign) VALUES ( @Picture )"

cmd = New SqlCommand(strSQL, Cn)
cmd.Parameters.Add(New SqlParameter("@Picture", SqlDbType.Image)).Value = arrImage

[removed email]

Jul 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.