473,320 Members | 1,854 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,320 software developers and data experts.

Using C# to insert blob into Oracle

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
11 22930
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ATK | last post by:
Hi, I'm trying to upload a image file to a oracle DB and i need to only use ODBC functions. In db i have a LONG RAW column (if this is not correct, please tell me). I'm getting the error from...
7
by: sime | last post by:
Hi, I have a blob field in a mysql database table. I want to copy a blob from one record to another. I am having trouble transferring the data via a php variable. Maybe I need to addslashes or...
3
by: Chris | last post by:
Hi all, I am trying to use System.Data.ODBC to insert a file into a binary field in SQL Server 2000. Now, before you yell at me, the reason I am doing this is that I am only writing intitial...
2
by: mrkrishnan.ms | last post by:
Hi i would like to know whether we can save data of 2GB capacity into a table in one statement using C++. I would say the data type would be BLOB or any LOB of a max of 2 gb DATA . PLEASE HELP...
0
by: yoyo | last post by:
DOes anybody have a working example of how do make this work? I've tried everything I could find, Clara patch, many non-working examples using pack, baseencode, addslashes, str_replace, bin2hex,...
11
by: Peter Afonin | last post by:
Hello, I have Word documents stored in the Oracle database in the BLOB field that I need to retrieve. I've found the way of doing it: While dr.Read sName = dr("TE_PM_ATTACH_NAME") bLob =...
9
by: matt | last post by:
hello, im doing my first ASP.NET app that inserts & retrieves files from Oracle (no need for a discussion on *that*!). i learned first-hand of the somewhat awkward technique for inserting...
1
by: shallowpool | last post by:
Can someone provide me the simple syntax necessary to insert or update to a row containing a single BLOB column, where the BLOB data will be obtained from a file? This is on a linux installation. ...
2
by: simonyong | last post by:
Hello, anyone I had search for few days with how to save file when user choose a file name from listbox and i will search the file from database and user can save it into their desktop what I had...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.