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
anil dhopare
NA
1
0
Not able to read the image saved in database
Sep 17 2010 12:18 AM
The error is :
A generic error occurred in GDI+.
i am providing u the Read button click code below:
private void btnReadImage_Click(object sender, EventArgs e)
{
if (txtBrowse.Text != "")
{
String sql = "select UserPhoto, UserID, UserName,UserEmail, UserDescription from User_info where UserID='1'";
SqlConnection conn = new SqlConnection(@"Password=Sql2008;Persist Security Info=True;User ID=sa;Initial Catalog=anil;Data Source=SST-08\SQL2008");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
DataSet ds = new DataSet("User_info");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds, "User_info");
DataRow row = ds.Tables["User_info"].Rows[0];
byte[] rawdata = new byte[0];
rawdata = (byte[])row["UserPhoto"];
int len = new int();
len = rawdata.GetUpperBound(0);
FileStream fs = new FileStream(savedImageName, FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(rawdata, 0, len);
fs.Close();
curImage = Image.FromFile(savedImageName);
pictureBox1.Image = curImage;
//conn.Close();
if (conn != null)
{
if (conn.State == ConnectionState.Open)
conn.Close();
conn.Dispose();
}
}
else
{
MessageBox.Show("First upload the image ");
}
Reply
Answers (
1
)
SQLBulkcopy
Refresh VS 2010 rdlc files (report viewer)