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

Problem ...

P: n/a
.... I'm trying to retrieve an Image from Image field
of a remote SQLServer Table.

The code is simple:

SqlConnection c = new SqlConnection("Data
Source=XX.XX.XXX.XX;Initial Catalog=STFManager;Persist Security
Info=True;User ID=XXXX;password=XXXX");
c.Open();
SqlCommand sc = new SqlCommand("select photo from images where
id = 'ce35d01b-5201-42b1-819b-300edc0d3daf'", c);
SqlDataReader r = sc.ExecuteReader();
r.Read();
f.e:) MessageBox.Show(r[0].ToString());
r.Dispose();
c.Close();
return;

Everytime doing that I got a timeout exception regardless of the
size of an image. It could be caused by the network slowness or
lags but the same command executed by SQLServer Query designer runs
almoust imediatelly ...

What's wrong? Some bug may be?
May 11 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What's the r[0].ToString() ?!
If you are getting Image you need to use array of bytes

.... I'm trying to retrieve an Image from Image field
of a remote SQLServer Table.
The code is simple:
SqlConnection c = new SqlConnection("Data
Source=XX.XX.XXX.XX;Initial Catalog=STFManager;Persist Security
Info=True;User ID=XXXX;password=XXXX");
c.Open();
SqlCommand sc = new SqlCommand("select photo from images where
id = 'ce35d01b-5201-42b1-819b-300edc0d3daf'", c);
SqlDataReader r = sc.ExecuteReader();
r.Read();
f.e:) MessageBox.Show(r[0].ToString());
r.Dispose();
c.Close();
return;

Everytime doing that I got a timeout exception regardless of the
size of an image. It could be caused by the network slowness or
lags but the same command executed by SQLServer Query designer runs
almoust imediatelly ...


--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

May 11 '06 #2

P: n/a
I do. r[0] is a first column in the query result wchich is
array of bytes. MessageBox is not important. The problem is
that the DataReader isn't filled because the timeout error...
Here's anodher piece of code without Messagebox but
stil isn't working:

SqlConnection c = new SqlConnection("Data Source=62.69.192.75;Initial
Catalog=STFManager;Persist Security Info=True;User
ID=Jacek;Password=payne;Packet Size=4096");
c.Open();
SqlCommand cmd = new SqlCommand("select photo from images",c);
SqlDataReader r = cmd.ExecuteReader();
r.Read();
Byte[] image = (Byte[])r["photo"];
r.Close();
c.Close();

The same command throught Query analyzer runs fine ...

May 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.