TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Goran Bibic
482
2.9k
197.9k
Save and retrieve Image c#
Dec 4 2018 3:36 AM
I have app, but have some simple solution.
Using this code to insert into sql and working fine.
But i have 2000 employes and have problem with database was too big when put inside pictures of all workers
I need some help or solution, to save some loaction with file name exmp. c:\some folder\imageofemployee.jpg
When click on datagrid row (selection changed) to show picture from that location
Not put in sql image, just file location.
Some help???
I hope to good explane
//Insert into sql
byte
[] img_arr =
null
;
MemoryStream ms =
new
MemoryStream();
//dataPictureBox.Image.Save(ms, dataPictureBox.Image.RawFormat);
bool
isNullOrEmpty = pictureBox1 ==
null
|| pictureBox1.Image ==
null
;
if
(!isNullOrEmpty)
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
img_arr = ms.GetBuffer();
using
(SqlConnection openCon =
new
SqlConnection(cs))
{
string
saveStaff =
"declare @maxNo integer = 0 select @maxNo = isnull(max(redni_broj), 0) from [dbo].[radnici]; Set @maxNo=@maxNo+1; INSERT INTO dbo.radnici (redni_broj, data) VALUES (@maxNo,@data)"
;
using
(SqlCommand querySaveStaff =
new
SqlCommand(saveStaff))
{
querySaveStaff.Connection = openCon;
querySaveStaff.Parameters.AddWithValue(
"@data"
, img_arr);
openCon.Open();
querySaveStaff.ExecuteNonQuery();
openCon.Close();
}
Reply
Answers (
1
)
Error reading data from SQL Server ?
i want to mark a cell in a grid view and it should be a sing