hi,
i want to save the MS Word data (not the Word file) to a database,
so i copy the Word data to clipboard first,and then get the data to a
DataObject object, and then try the code below,
Formatter.Seria lize(StreamTemp , dbObject); //but it can't be Serialized,
StreamTemp.Clos e();
Return StreamTemp.GetB uffer() ;
plz, thanks for any help 5 2879
Try copying to the clipboard with DataFormat.Rtf .
Then you can copy out from clipboard and try casting to byte array.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"cgd" wrote:
hi,
i want to save the MS Word data (not the Word file) to a database,
so i copy the Word data to clipboard first,and then get the data to a
DataObject object, and then try the code below,
Formatter.Seria lize(StreamTemp , dbObject); //but it can't be Serialized,
StreamTemp.Clos e();
Return StreamTemp.GetB uffer() ;
plz, thanks for any help
You don't want to serialize the IDataObject but instead the actual
data. Use GetFormats() to identify the available formats and
GetData(format) to get the real data. Once you get the data, then you
can serialize that.
Note that some formats can generate a FatalExecutionE ngineError which
can shut down your app and not even be caught with a try/catch so be
careful.
Formats supported by MS Word 2003 which can be retrieved in .NET 2.0:
Object Descriptor
Rich Text Format
HTML Format
System.String
UnicodeText
Text
And formats which generate the nasty error (at least in my testing):
EnhancedMetafil e
MetaFilePict
Embed Source
Link Source
Link Source Descriptor
ObjectLink
When run in debugger I can get this info, but when run normally the
app just shuts down:
FatalExecutionE ngineError was detected
Message: The runtime has encountered a fatal error. The address of the
error was at 0x79f1c184, on thread 0x608. The error code is
0xc0000005. This error may be a bug in the CLR or in the unsafe or
non-verifiable portions of user code. Common sources of this bug
include user marshaling errors for COM-interop or PInvoke, which may
corrupt the stack.
HTH,
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Tue, 24 Apr 2007 18:10:50 +0800, "cgd" <xg@163.comwrot e:
>hi, i want to save the MS Word data (not the Word file) to a database, so i copy the Word data to clipboard first,and then get the data to a DataObject object, and then try the code below,
Formatter.Seria lize(StreamTemp , dbObject); //but it can't be Serialized,
StreamTemp.Clos e();
Return StreamTemp.GetB uffer() ; plz, thanks for any help
Peter:
thank you very much,
i copy to clipboard with fromat RTF,
the i get the data from clipboard is string ,then i save the string to DB,
that's ok. thanks.:)
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comдÈëÏûÏ¢
news:A5******** *************** ***********@mic rosoft.com...
Try copying to the clipboard with DataFormat.Rtf .
Then you can copy out from clipboard and try casting to byte array.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"cgd" wrote:
>hi, i want to save the MS Word data (not the Word file) to a database, so i copy the Word data to clipboard first,and then get the data to a DataObject object, and then try the code below,
Formatter.Seria lize(StreamTemp , dbObject); //but it can't be Serialized, StreamTemp.Clos e(); Return StreamTemp.GetB uffer() ; plz, thanks for any help
Thank you ,Sam. I get it.
"Samuel R. Neff" <sa********@nom ail.com????
news:6m******** *************** *********@4ax.c om...
>
You don't want to serialize the IDataObject but instead the actual
data. Use GetFormats() to identify the available formats and
GetData(format) to get the real data. Once you get the data, then you
can serialize that.
Note that some formats can generate a FatalExecutionE ngineError which
can shut down your app and not even be caught with a try/catch so be
careful.
Formats supported by MS Word 2003 which can be retrieved in .NET 2.0:
Object Descriptor
Rich Text Format
HTML Format
System.String
UnicodeText
Text
And formats which generate the nasty error (at least in my testing):
EnhancedMetafil e
MetaFilePict
Embed Source
Link Source
Link Source Descriptor
ObjectLink
When run in debugger I can get this info, but when run normally the
app just shuts down:
FatalExecutionE ngineError was detected
Message: The runtime has encountered a fatal error. The address of the
error was at 0x79f1c184, on thread 0x608. The error code is
0xc0000005. This error may be a bug in the CLR or in the unsafe or
non-verifiable portions of user code. Common sources of this bug
include user marshaling errors for COM-interop or PInvoke, which may
corrupt the stack.
HTH,
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Tue, 24 Apr 2007 18:10:50 +0800, "cgd" <xg@163.comwrot e:
>>hi, i want to save the MS Word data (not the Word file) to a database, so i copy the Word data to clipboard first,and then get the data to a DataObject object, and then try the code below,
Formatter.Seri alize(StreamTem p, dbObject); //but it can't be Serialized, StreamTemp.Clo se(); Return StreamTemp.GetB uffer() ; plz, thanks for any help
I find Get the Word data as RTF string is biger than the word DOC file,
So, I'd better Save the word to database as a DOC file,
It's better Save the document to database in memory. than save it to disk
and then open as stream to Database,how to do this ?
thank you.
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comдÈëÏûÏ¢
news:A5******** *************** ***********@mic rosoft.com...
Try copying to the clipboard with DataFormat.Rtf .
Then you can copy out from clipboard and try casting to byte array.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"cgd" wrote:
>hi, i want to save the MS Word data (not the Word file) to a database, so i copy the Word data to clipboard first,and then get the data to a DataObject object, and then try the code below,
Formatter.Seria lize(StreamTemp , dbObject); //but it can't be Serialized, StreamTemp.Clos e(); Return StreamTemp.GetB uffer() ; plz, thanks for any help This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul |
last post by:
Hi,
(First apologies if this is not the most relevant place to post this
but I wasn't sure of where was and I am writing my app in VB.)
I'm attempting to parse a binary file for which I have the format. The
format states that the general packet format is as follows
Message header
Hex Length of whole binary packet
|
by: Bryan Parkoff |
last post by:
I have two variables: "char A" and "short B". I can be able to convert
from A to B using explicit case conversion with no problem like "B = short
(A);". Right now, I have two variables: "char T" and "short A". T has
an array of six elements. I desire to capture first element and second
element as two bytes into word as short.
The problem is that "A" captures only one element instead of two
elements. I have looked at machine language...
|
by: Oliver Knoll |
last post by:
Ok,
I've searched this group for Big/Little endian issues, don't kill me,
I know endianess issues have been discussed a 1000 times. But my
question is a bit different:
I've seen the follwing function several times, it converts data stored
in Big Endian (BE) format into host native format (LE on LE machines,
BE on BE machines):
|
by: Sisnaz |
last post by:
I'm sending a message from VB.net (2003) to a C++ app via TCP sockets of
values 1 to 328. The message is a WORD value where I have to manage both
bytes for the WORD. I'm sending and receiving data from the C++ app with no
problem between the values of 1 to 127 and 256 to 328, but the application
receives garabage between 128 and 255. My current test syntax is as follows:
Dim nodeid As Integer = CType(txtMessage.Text, Integer)
Dim...
|
by: K B |
last post by:
I'm using the following in .NET to save a Word document to a SQL image
column:
Dim iImageSize As Integer = FileUpload.PostedFile.ContentLength
Dim picbyte() As Byte = New Byte(iImageSize) {}
FileUpload.PostedFile.InputStream.Read(picbyte, 0, iImageSize)
Seems to work fine, but when I retrieve the image and use the following
to load it, I get a lot of characters, etc. What am I doing wrong
please?
| |
by: Andy |
last post by:
Hi, I have an XML document that uses namespaces (it is from a Word 2007
file). I want to retrieve all the "t" elements that belong to the
"w" namespace (<w:t>) using XPath from VB.NET 2003 (.NET framework
1.1).
I've successfully loaded the document into a XmlDocument DOM parser
(I can dump the contents using OuterXML).
And, I've created a XmlNamespaceManager and assigned it the "w"
namespace.
|
by: koraykazgan |
last post by:
Hi all,
I am using a WebService in ASP.Net 2.0 to retrieve Data in XTHML format. I want to put this data in a Word Document and send this document to the client. Till now, I just used Response.AddHeader and set the type to "Application/MSWord". It was a plain text file, but because of the extension .doc, the user coult opened the document in word. And Word is able to show HTML Documents, so everything worked fine.
But now, I have to put...
|
by: artist |
last post by:
Hi all,
I have the following:
byte msgData = new byte;
ushort aaa = 0xFFFA;
Now I would like to store that variable aaa in the array
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |