943,816 Members | Top Members by Rank

Ad:
Jul 23rd, 2009
0

PictureBox/Image - Stored to SQL Database

Expand Post »
Hello My Friends,

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

Need advice please.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fauzanf is offline Offline
6 posts
since Sep 2008
Jul 23rd, 2009
0

Re: PictureBox/Image - Stored to SQL Database

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
m_coombes is offline Offline
5 posts
since May 2009
Jul 23rd, 2009
0

Re: PictureBox/Image - Stored to SQL Database

ok,

so... do you have a sample code?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fauzanf is offline Offline
6 posts
since Sep 2008
Jul 24th, 2009
0

Re: PictureBox/Image - Stored to SQL Database

Click to Expand / Collapse  Quote originally posted by fauzanf ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
m_coombes is offline Offline
5 posts
since May 2009
Jul 24th, 2009
0

Re: PictureBox/Image - Stored to SQL Database

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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Jul 24th, 2009
0

Re: PictureBox/Image - Stored to SQL Database

Click to Expand / Collapse  Quote originally posted by m_coombes ...
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.
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Oct 1st, 2009
0

Re: PictureBox/Image - Stored to SQL Database

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();
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
karthikvcsharp is offline Offline
2 posts
since Oct 2009
Oct 1st, 2009
0

Re: PictureBox/Image - Stored to SQL Database

Wrong forum K, that is .NET code and this is the "classic" Visual Basic forum!
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: help me out with this
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: sapi 5.1 and vb6 help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC