PictureBox/Image - Stored to SQL Database

Reply

Join Date: Sep 2008
Posts: 6
Reputation: fauzanf is an unknown quantity at this point 
Solved Threads: 0
fauzanf's Avatar
fauzanf fauzanf is offline Offline
Newbie Poster

PictureBox/Image - Stored to SQL Database

 
0
  #1
Jul 23rd, 2009
Hello My Friends,

I have a question...
How can i add a photo/picture into SQL Server 2000....?

Need advice please.
Regards,
Fauzan
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 5
Reputation: m_coombes is an unknown quantity at this point 
Solved Threads: 0
m_coombes m_coombes is offline Offline
Newbie Poster

Re: PictureBox/Image - Stored to SQL Database

 
0
  #2
Jul 23rd, 2009
Hi Fauzan

The short answer is "you can't" as SQL only handles text, not images.

You can however create a table in SQL where you put the links to all the image files. Then in your report you can link the data that you want with that text link. You then take that text output from SQL, and through the formatting of your report you can use that retrieved link to load the picture.
Last edited by m_coombes; Jul 23rd, 2009 at 11:51 pm. Reason: poor grammar on my part
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 6
Reputation: fauzanf is an unknown quantity at this point 
Solved Threads: 0
fauzanf's Avatar
fauzanf fauzanf is offline Offline
Newbie Poster

Re: PictureBox/Image - Stored to SQL Database

 
0
  #3
Jul 23rd, 2009
ok,

so... do you have a sample code?
Regards,
Fauzan
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 5
Reputation: m_coombes is an unknown quantity at this point 
Solved Threads: 0
m_coombes m_coombes is offline Offline
Newbie Poster

Re: PictureBox/Image - Stored to SQL Database

 
0
  #4
Jul 24th, 2009
Originally Posted by fauzanf View Post
ok,

so... do you have a sample code?
That depends on your interface. If you are using pure SQL, just use a standard "INSERT" command.

The link to the MSDN article that explains it is here
http://msdn.microsoft.com/en-us/library/h54fa37c(VS.80).aspx
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

Re: PictureBox/Image - Stored to SQL Database

 
0
  #5
Jul 24th, 2009
Try following links. u will get some idea of storing images in a SQL Server table.
http://www.codersource.net/csharp_re..._database.aspx

http://www.c-sharpcorner.com/UploadF...f-5addf5b77ca4
Regards
Shaik Akthar
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 809
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 147
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: PictureBox/Image - Stored to SQL Database

 
0
  #6
Jul 24th, 2009
Originally Posted by m_coombes View Post
Hi Fauzan

The short answer is "you can't" as SQL only handles text, not images.

You can however create a table in SQL where you put the links to all the image files. Then in your report you can link the data that you want with that text link. You then take that text output from SQL, and through the formatting of your report you can use that retrieved link to load the picture.
You really should follow up with that the long answer is that you can but this is the preferred method by many, that is just to store the path to the file in the database and not the file itself. And just for you information there are a couple of ways to do it.

OP. Use the Data Form Wizard, which you will find under Add-Ins>Add-In Manager and use the ODBC option which means before you use it you will have to create an ODBC DSN. Use each form option in combination with code/class/control and save project for future use. Then once you are ready to go to a DNS Less connection see http://www.connectionstrings.com


Good Luck
Last edited by vb5prgrmr; Jul 24th, 2009 at 10:36 am.
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: karthikvcsharp is an unknown quantity at this point 
Solved Threads: 0
karthikvcsharp karthikvcsharp is offline Offline
Newbie Poster

Re: PictureBox/Image - Stored to SQL Database

 
0
  #7
Oct 1st, 2009
hi friend you can easily save an photo and image to the database. check out this code

private void button1_Click(object sender, EventArgs e)
{

OpenFileDialog dlg = new OpenFileDialog();

dlg.Title = "Open Photo";

if (dlg.ShowDialog() == DialogResult.OK)
{
try
{
pictureBox1.Image = new Bitmap(dlg.OpenFile());

name = dlg.FileName;
txtname.Text = dlg.SafeFileName;
}
catch (Exception ex)
{
MessageBox.Show("Unable to load file: " + ex.Message);
}
}

dlg.Dispose();
}
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 809
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 147
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: PictureBox/Image - Stored to SQL Database

 
0
  #8
Oct 1st, 2009
Wrong forum K, that is .NET code and this is the "classic" Visual Basic forum!
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC