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

Using C# to insert blob into Oracle

P: n/a
I have setup an Oracle table which contains a blob field. How do I insert
data into this field using C# and ADO.net?
Nov 16 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Chris,

The provider for Oracle should represent the field as a byte array. You
should be able to assign a new byte array to this field in a data set, and
then update the field through an ad-hoc query or stored procedure, just like
you would any other value in the database.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:Oo**************@TK2MSFTNGP14.phx.gbl...
I have setup an Oracle table which contains a blob field. How do I insert
data into this field using C# and ADO.net?

Nov 16 '05 #2

P: n/a
How do I convert a C# string into a byte array? Which class do I use, the
StreamReader, StringReader, etc? Any sample code is appreciated!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eT**************@TK2MSFTNGP10.phx.gbl...
Chris,

The provider for Oracle should represent the field as a byte array. You should be able to assign a new byte array to this field in a data set, and
then update the field through an ad-hoc query or stored procedure, just like you would any other value in the database.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:Oo**************@TK2MSFTNGP14.phx.gbl...
I have setup an Oracle table which contains a blob field. How do I insert data into this field using C# and ADO.net?


Nov 16 '05 #3

P: n/a
Chris,

It depends on the format of the string. Is it in hex, or is it base64
encoded, or something else?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert a C# string into a byte array? Which class do I use, the
StreamReader, StringReader, etc? Any sample code is appreciated!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:eT**************@TK2MSFTNGP10.phx.gbl...
Chris,

The provider for Oracle should represent the field as a byte array.

You
should be able to assign a new byte array to this field in a data set,
and
then update the field through an ad-hoc query or stored procedure, just

like
you would any other value in the database.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:Oo**************@TK2MSFTNGP14.phx.gbl...
>I have setup an Oracle table which contains a blob field. How do I insert > data into this field using C# and ADO.net?
>
>



Nov 16 '05 #4

P: n/a
The string is just text.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Chris,

It depends on the format of the string. Is it in hex, or is it base64
encoded, or something else?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How do I convert a C# string into a byte array? Which class do I use, the StreamReader, StringReader, etc? Any sample code is appreciated!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:eT**************@TK2MSFTNGP10.phx.gbl...
Chris,

The provider for Oracle should represent the field as a byte array.

You
should be able to assign a new byte array to this field in a data set,
and
then update the field through an ad-hoc query or stored procedure, just

like
you would any other value in the database.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:Oo**************@TK2MSFTNGP14.phx.gbl...
>I have setup an Oracle table which contains a blob field. How do I

insert
> data into this field using C# and ADO.net?
>
>



Nov 16 '05 #5

P: n/a
Chris,

Yes, it is just text, but you want a byte array from it? There are many
ways to convert text to a byte array. Is the text representative of a
binary value, or is it actual text, and you want to store it in a binary
form in the table?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
The string is just text.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Chris,

It depends on the format of the string. Is it in hex, or is it
base64
encoded, or something else?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> How do I convert a C# string into a byte array? Which class do I use, the > StreamReader, StringReader, etc? Any sample code is appreciated!
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:eT**************@TK2MSFTNGP10.phx.gbl...
>> Chris,
>>
>> The provider for Oracle should represent the field as a byte
>> array.
> You
>> should be able to assign a new byte array to this field in a data set,
>> and
>> then update the field through an ad-hoc query or stored procedure,
>> just
> like
>> you would any other value in the database.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Chris Fink" <ch********@gmail.com> wrote in message
>> news:Oo**************@TK2MSFTNGP14.phx.gbl...
>> >I have setup an Oracle table which contains a blob field. How do I
> insert
>> > data into this field using C# and ADO.net?
>> >
>> >
>>
>>
>
>



Nov 16 '05 #6

P: n/a
Sorry for not explaining in more detail. I want to take a string, ex: "This
is a test" and insert it into a blob field. So I will need to first convert
the string into a byte[] and then perform the insert. In actualitym this
string could be text as presented, or more common xml documents.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O7**************@TK2MSFTNGP12.phx.gbl...
Chris,

Yes, it is just text, but you want a byte array from it? There are many ways to convert text to a byte array. Is the text representative of a
binary value, or is it actual text, and you want to store it in a binary
form in the table?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
The string is just text.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Chris,

It depends on the format of the string. Is it in hex, or is it
base64
encoded, or something else?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> How do I convert a C# string into a byte array? Which class do I use,
the
> StreamReader, StringReader, etc? Any sample code is appreciated!
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:eT**************@TK2MSFTNGP10.phx.gbl...
>> Chris,
>>
>> The provider for Oracle should represent the field as a byte
>> array.
> You
>> should be able to assign a new byte array to this field in a data

set, >> and
>> then update the field through an ad-hoc query or stored procedure,
>> just
> like
>> you would any other value in the database.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Chris Fink" <ch********@gmail.com> wrote in message
>> news:Oo**************@TK2MSFTNGP14.phx.gbl...
>> >I have setup an Oracle table which contains a blob field. How do I
> insert
>> > data into this field using C# and ADO.net?
>> >
>> >
>>
>>
>
>



Nov 16 '05 #7

P: n/a
Chris,

In that case, you can use the GetBytes method on the ASCIIEncoder or the
UnicodeEncoder (depending on the type of text) and use that to get the bytes
that you store in the blob field.

However, I have to ask, why not just use a text field?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Sorry for not explaining in more detail. I want to take a string, ex:
"This
is a test" and insert it into a blob field. So I will need to first
convert
the string into a byte[] and then perform the insert. In actualitym this
string could be text as presented, or more common xml documents.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:O7**************@TK2MSFTNGP12.phx.gbl...
Chris,

Yes, it is just text, but you want a byte array from it? There are

many
ways to convert text to a byte array. Is the text representative of a
binary value, or is it actual text, and you want to store it in a binary
form in the table?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> The string is just text.
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP14.phx.gbl...
>> Chris,
>>
>> It depends on the format of the string. Is it in hex, or is it
>> base64
>> encoded, or something else?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Chris Fink" <ch********@gmail.com> wrote in message
>> news:%2****************@TK2MSFTNGP15.phx.gbl...
>> > How do I convert a C# string into a byte array? Which class do I use, > the
>> > StreamReader, StringReader, etc? Any sample code is appreciated!
>> >
>> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
>> > wrote
>> > in
>> > message news:eT**************@TK2MSFTNGP10.phx.gbl...
>> >> Chris,
>> >>
>> >> The provider for Oracle should represent the field as a byte
>> >> array.
>> > You
>> >> should be able to assign a new byte array to this field in a data set, >> >> and
>> >> then update the field through an ad-hoc query or stored procedure,
>> >> just
>> > like
>> >> you would any other value in the database.
>> >>
>> >> Hope this helps.
>> >>
>> >>
>> >> --
>> >> - Nicholas Paldino [.NET/C# MVP]
>> >> - mv*@spam.guard.caspershouse.com
>> >>
>> >> "Chris Fink" <ch********@gmail.com> wrote in message
>> >> news:Oo**************@TK2MSFTNGP14.phx.gbl...
>> >> >I have setup an Oracle table which contains a blob field. How do
>> >> >I
>> > insert
>> >> > data into this field using C# and ADO.net?
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 16 '05 #8

P: n/a
Oracle VARCHAR2 field is limited in size, BLOB is not. Many of the XML
transactions may exceed the VARCHAR2 limit.

Thanks for your help.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e7**************@TK2MSFTNGP09.phx.gbl...
Chris,

In that case, you can use the GetBytes method on the ASCIIEncoder or the UnicodeEncoder (depending on the type of text) and use that to get the bytes that you store in the blob field.

However, I have to ask, why not just use a text field?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Sorry for not explaining in more detail. I want to take a string, ex:
"This
is a test" and insert it into a blob field. So I will need to first
convert
the string into a byte[] and then perform the insert. In actualitym this string could be text as presented, or more common xml documents.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:O7**************@TK2MSFTNGP12.phx.gbl...
Chris,

Yes, it is just text, but you want a byte array from it? There are

many
ways to convert text to a byte array. Is the text representative of a
binary value, or is it actual text, and you want to store it in a binary form in the table?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> The string is just text.
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP14.phx.gbl...
>> Chris,
>>
>> It depends on the format of the string. Is it in hex, or is it
>> base64
>> encoded, or something else?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Chris Fink" <ch********@gmail.com> wrote in message
>> news:%2****************@TK2MSFTNGP15.phx.gbl...
>> > How do I convert a C# string into a byte array? Which class do I

use,
> the
>> > StreamReader, StringReader, etc? Any sample code is appreciated!
>> >
>> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
>> > wrote
>> > in
>> > message news:eT**************@TK2MSFTNGP10.phx.gbl...
>> >> Chris,
>> >>
>> >> The provider for Oracle should represent the field as a byte
>> >> array.
>> > You
>> >> should be able to assign a new byte array to this field in a data

set,
>> >> and
>> >> then update the field through an ad-hoc query or stored procedure, >> >> just
>> > like
>> >> you would any other value in the database.
>> >>
>> >> Hope this helps.
>> >>
>> >>
>> >> --
>> >> - Nicholas Paldino [.NET/C# MVP]
>> >> - mv*@spam.guard.caspershouse.com
>> >>
>> >> "Chris Fink" <ch********@gmail.com> wrote in message
>> >> news:Oo**************@TK2MSFTNGP14.phx.gbl...
>> >> >I have setup an Oracle table which contains a blob field. How do >> >> >I
>> > insert
>> >> > data into this field using C# and ADO.net?
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 16 '05 #9

P: n/a
Now that I am on the correct path, the string to byte array was not
difficult. However, the insert of the byte array is throwing an Oracle
Exception, {"ORA-01465: invalid hex number" }. It is obvious as to why when
looking at the SQL (System.Byte[]) , but I am not sure what I need to do to
pass this byte array into the Blob field properly in my SQL statement.

Following is the code, notice that the runtime SQL string is as follows:
INSERT INTO INBOUNDWEBSERVICES (STRUCTUREID, STATUS, LASTUPDATEDBY, MSGIN)
VALUES ('structureID10','Test status1','111','System.Byte[]')

string asciiString = "Test String";
Encoding ascii = Encoding.ASCII;

// Convert the string into a byte[].
byte[] baMsgIn = ascii.GetBytes(asciiString);

string sql = String.Format(("INSERT INTO INBOUNDWEBSERVICES (STRUCTUREID,
STATUS, LASTUPDATEDBY, MSGIN) VALUES ('{0}','{1}','{2}','{3}')"),
structureID, status, lastUpdatedBy, baMsgIn);
try
{
OracleConnection cn = new OracleConnection(DATASOURCE8I);
cn.Open();
OracleCommand cmd = new OracleCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
cmd.Connection = cn;
cmd.ExecuteNonQuery();
cn.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
"Chris Fink" <ch********@gmail.com> wrote in message
news:ei**************@TK2MSFTNGP10.phx.gbl...
Oracle VARCHAR2 field is limited in size, BLOB is not. Many of the XML
transactions may exceed the VARCHAR2 limit.

Thanks for your help.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:e7**************@TK2MSFTNGP09.phx.gbl...
Chris,

In that case, you can use the GetBytes method on the ASCIIEncoder or

the
UnicodeEncoder (depending on the type of text) and use that to get the

bytes
that you store in the blob field.

However, I have to ask, why not just use a text field?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Sorry for not explaining in more detail. I want to take a string, ex:
"This
is a test" and insert it into a blob field. So I will need to first
convert
the string into a byte[] and then perform the insert. In actualitym this string could be text as presented, or more common xml documents.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O7**************@TK2MSFTNGP12.phx.gbl...
> Chris,
>
> Yes, it is just text, but you want a byte array from it? There are many
> ways to convert text to a byte array. Is the text representative of a> binary value, or is it actual text, and you want to store it in a binary> form in the table?
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "Chris Fink" <ch********@gmail.com> wrote in message
> news:%2****************@TK2MSFTNGP15.phx.gbl...
> > The string is just text.
> >
> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> > wrote
> > in
> > message news:%2****************@TK2MSFTNGP14.phx.gbl...
> >> Chris,
> >>
> >> It depends on the format of the string. Is it in hex, or is it> >> base64
> >> encoded, or something else?
> >>
> >>
> >> --
> >> - Nicholas Paldino [.NET/C# MVP]
> >> - mv*@spam.guard.caspershouse.com
> >>
> >> "Chris Fink" <ch********@gmail.com> wrote in message
> >> news:%2****************@TK2MSFTNGP15.phx.gbl...
> >> > How do I convert a C# string into a byte array? Which class do I use,
> > the
> >> > StreamReader, StringReader, etc? Any sample code is appreciated!> >> >
> >> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>> >> > wrote
> >> > in
> >> > message news:eT**************@TK2MSFTNGP10.phx.gbl...
> >> >> Chris,
> >> >>
> >> >> The provider for Oracle should represent the field as a byte> >> >> array.
> >> > You
> >> >> should be able to assign a new byte array to this field in a data set,
> >> >> and
> >> >> then update the field through an ad-hoc query or stored procedure,> >> >> just
> >> > like
> >> >> you would any other value in the database.
> >> >>
> >> >> Hope this helps.
> >> >>
> >> >>
> >> >> --
> >> >> - Nicholas Paldino [.NET/C# MVP]
> >> >> - mv*@spam.guard.caspershouse.com
> >> >>
> >> >> "Chris Fink" <ch********@gmail.com> wrote in message
> >> >> news:Oo**************@TK2MSFTNGP14.phx.gbl...
> >> >> >I have setup an Oracle table which contains a blob field. How do> >> >> >I
> >> > insert
> >> >> > data into this field using C# and ADO.net?
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>



Nov 16 '05 #10

P: n/a
I should also note that my connection to Oracle is via a System DSN using MS
ODBC provider for Oracle. In my C# class, I am making ADO.NET calls using
the OracleConnection, OracleCommand objects from the added reference
Oracle.DataAccess.

Not sure if any of that matters, but just wanted to point that out.

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Now that I am on the correct path, the string to byte array was not
difficult. However, the insert of the byte array is throwing an Oracle
Exception, {"ORA-01465: invalid hex number" }. It is obvious as to why when looking at the SQL (System.Byte[]) , but I am not sure what I need to do to pass this byte array into the Blob field properly in my SQL statement.

Following is the code, notice that the runtime SQL string is as follows:
INSERT INTO INBOUNDWEBSERVICES (STRUCTUREID, STATUS, LASTUPDATEDBY, MSGIN)
VALUES ('structureID10','Test status1','111','System.Byte[]')

string asciiString = "Test String";
Encoding ascii = Encoding.ASCII;

// Convert the string into a byte[].
byte[] baMsgIn = ascii.GetBytes(asciiString);

string sql = String.Format(("INSERT INTO INBOUNDWEBSERVICES (STRUCTUREID,
STATUS, LASTUPDATEDBY, MSGIN) VALUES ('{0}','{1}','{2}','{3}')"),
structureID, status, lastUpdatedBy, baMsgIn);
try
{
OracleConnection cn = new OracleConnection(DATASOURCE8I);
cn.Open();
OracleCommand cmd = new OracleCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
cmd.Connection = cn;
cmd.ExecuteNonQuery();
cn.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
"Chris Fink" <ch********@gmail.com> wrote in message
news:ei**************@TK2MSFTNGP10.phx.gbl...
Oracle VARCHAR2 field is limited in size, BLOB is not. Many of the XML
transactions may exceed the VARCHAR2 limit.

Thanks for your help.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e7**************@TK2MSFTNGP09.phx.gbl...
Chris,

In that case, you can use the GetBytes method on the ASCIIEncoder or
the
UnicodeEncoder (depending on the type of text) and use that to get the

bytes
that you store in the blob field.

However, I have to ask, why not just use a text field?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chris Fink" <ch********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
> Sorry for not explaining in more detail. I want to take a string,
ex: > "This
> is a test" and insert it into a blob field. So I will need to first
> convert
> the string into a byte[] and then perform the insert. In actualitym

this
> string could be text as presented, or more common xml documents.
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote > in
> message news:O7**************@TK2MSFTNGP12.phx.gbl...
>> Chris,
>>
>> Yes, it is just text, but you want a byte array from it? There are > many
>> ways to convert text to a byte array. Is the text representative of a
>> binary value, or is it actual text, and you want to store it in a binary
>> form in the table?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Chris Fink" <ch********@gmail.com> wrote in message
>> news:%2****************@TK2MSFTNGP15.phx.gbl...
>> > The string is just text.
>> >
>> > "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> >> > wrote
>> > in
>> > message news:%2****************@TK2MSFTNGP14.phx.gbl...
>> >> Chris,
>> >>
>> >> It depends on the format of the string. Is it in hex, or is

it >> >> base64
>> >> encoded, or something else?
>> >>
>> >>
>> >> --
>> >> - Nicholas Paldino [.NET/C# MVP]
>> >> - mv*@spam.guard.caspershouse.com
>> >>
>> >> "Chris Fink" <ch********@gmail.com> wrote in message
>> >> news:%2****************@TK2MSFTNGP15.phx.gbl...
>> >> > How do I convert a C# string into a byte array? Which class
do I > use,
>> > the
>> >> > StreamReader, StringReader, etc? Any sample code is appreciated! >> >> >
>> >> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> >> >> > wrote
>> >> > in
>> >> > message news:eT**************@TK2MSFTNGP10.phx.gbl...
>> >> >> Chris,
>> >> >>
>> >> >> The provider for Oracle should represent the field as a byte >> >> >> array.
>> >> > You
>> >> >> should be able to assign a new byte array to this field in a data > set,
>> >> >> and
>> >> >> then update the field through an ad-hoc query or stored

procedure,
>> >> >> just
>> >> > like
>> >> >> you would any other value in the database.
>> >> >>
>> >> >> Hope this helps.
>> >> >>
>> >> >>
>> >> >> --
>> >> >> - Nicholas Paldino [.NET/C# MVP]
>> >> >> - mv*@spam.guard.caspershouse.com
>> >> >>
>> >> >> "Chris Fink" <ch********@gmail.com> wrote in message
>> >> >> news:Oo**************@TK2MSFTNGP14.phx.gbl...
>> >> >> >I have setup an Oracle table which contains a blob field.

How do
>> >> >> >I
>> >> > insert
>> >> >> > data into this field using C# and ADO.net?
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 16 '05 #11

P: n/a
Chris Fink wrote:
I should also note that my connection to Oracle is via a System DSN using MS ODBC provider for Oracle.


Have you considered using a CLOB field instead of a BLOB ? If you are
inserting text data, this might be a better choice, although there you
cannot insert strings longer than 4000 characters in one string literal
using ODBC without Oracle host variables.
Nov 16 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.