473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

after converting Bitmap back to MemoryStream not saving proper image

I have a data grid view,in update button i wrote code like this:


Expand|Select|Wrap|Line Numbers
  1.     Dim cid As Integer
  2.             Dim dtid As Integer
  3.             Dim cmpname As String
  4.             Dim dtname As String
  5.             Dim dtPhone As String
  6.             Dim dtEmail As String
  7.             Dim dtimage As Image
  8.  
  9.  
  10.             For i As Integer = 0 To gv.RowCount - 2
  11.                 ' Dim rv = DirectCast(bSource.Current, DataRowView)
  12.                 Dim rv = DirectCast(gv.Rows(i).DataBoundItem, DataRowView)
  13.                 cid = rv.Row.Field(Of Integer)("Cid")
  14.  
  15.                 dtid = rv.Row.Field(Of Integer)("dtId")
  16.                 cmpname = rv.Row.Field(Of String)("CompanyName")
  17.                 dtname = rv.Row.Field(Of String)("Department")
  18.                 dtPhone = rv.Row.Field(Of String)("Phone")
  19.                 dtEmail = rv.Row.Field(Of String)("Email")
  20.  
  21.                 Using ms As New MemoryStream(rv.Row.Field(Of Byte())("empimage"))
  22.                     dtimage = New Bitmap(ms)
  23.                 End Using
  24.  
  25.                 adapter.UpdateCommand = New SqlCommand("UPDATE CompanyMaster_tbl SET CompanyName = @CompanyName", con.connect)
  26.                 adapter.UpdateCommand = New SqlCommand("update DepartmentMaster_tbl set dtName = @dtName,dtPhone = @dtPhone,dtEmail = @dtEmail,empimage=@dtimage  where dtId=@dtid", con.connect)
  27.                 adapter.UpdateCommand.Parameters.AddWithValue("@Cid", cid)
  28.                 adapter.UpdateCommand.Parameters.AddWithValue("@CompanyName", cmpname)
  29.                 adapter.UpdateCommand.Parameters.AddWithValue("@dtId", dtid)
  30.                 adapter.UpdateCommand.Parameters.AddWithValue("@dtName", dtname)
  31.                 adapter.UpdateCommand.Parameters.AddWithValue("@dtPhone", dtPhone)
  32.                 adapter.UpdateCommand.Parameters.AddWithValue("@dtEmail", dtEmail)
  33.                 adapter.UpdateCommand.Parameters.AddWithValue("@dtimage", dtimage)
  34.                 adapter.UpdateCommand.ExecuteNonQuery()
  35.             Next
while executing i am getting error in this line :**adapter.UpdateCommand.ExecuteNonQuery()**
Error:`No mapping exists from object type System.Drawing.Bitmap to a known managed provider native type`
so i made small change in my code ..change is
instead of this line '**adapter.UpdateCommand.Parameters.AddWithValue(" @dtimage", dtimage)**' i added code like this

Expand|Select|Wrap|Line Numbers
  1. Dim md As New MemoryStream()
  2.                 dtimage.Save(md, System.Drawing.Imaging.ImageFormat.Gif)
  3.                 Dim imagedata As Byte() = md.ToArray()
  4.      adapter.UpdateCommand.Parameters.AddWithValue("@dtimage", imagedata )
after adding this code am not getting any error..but not saving my image..that saving some another thing..what is wrong with my code
Jan 22 '14 #1
0 1011

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Christopher Kurtis Koeber | last post by:
Dear All, I am having problems saving an image to a memory stream to use it in an API function. The error occurs in the save method of the bitmap. It tells me that the arguement cannot be...
2
by: Bruce D | last post by:
I'm having a problem saving my bitmap in my MySQL database. Apparently it's too big...but it shouldn't be. Here's what I got: Dim bmpDocument As Bitmap = Bitmap.FromHbitmap(hDibCopy) ' get...
3
by: JamesB | last post by:
I am saving image files from my website using the downloaddata on the web client. This gives me a byte array, which I am then saving to a file with the following code: ' Create the new, empty...
9
by: Michael Tissington | last post by:
After converting from 6.0 to 2005 when I try to Compile my project I'm getting a LINK error Error 1 fatal error LNK1181: cannot open input file " ?/.obj" Any ideas how to fx this please ? ...
3
by: Asaf | last post by:
Hi, After converting my project from VS.NET 2003 to VS.NET 2005 I am receiving the error: The call is ambiguous between the following methods or properties: 'System.Math.Floor(decimal)' and...
6
by: Nathan Sokalski | last post by:
I recently converted some ASP.NET 1.1 projects of mine, created with Visual Studio .NET 2003, to Web Application Projects in Visual Studio .NET 2005 so that I could use ASP.NET 2.0 (All my ASP.NET...
2
by: Rainer Queck | last post by:
Hello Microsoft Support, It looks like there is a bug inside the VS2008 Pro IDE. I did quite a bit of debugging to narrow the problem down. Here is the result of my efforts: A VS2005 project...
2
by: keerthisreenu | last post by:
hai to all...!! iam working with Ms Access 2000. iam saving an image in the database. After that i want to retrive the same image from database and displaying it in the picture box. but its not...
6
by: gonella123 | last post by:
I am getting #Error while generating report, after converting the database from 2003 to 2007. The "#Error" when run the report. On this you have report elements use nested if-statements as...
2
by: Ashiie | last post by:
Hi, so yeah. what i'm trying to do is load an image from my database create some graphics to it. probably just some lines and marks and save it back to my database. here's so far what I got. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.