Insert BLOB using System.Data.ODBC

G

Guest

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 code against SQL, but this app will need to
be able to run against any ODBC compliant DB, so I am also not using stored
procedures.

I have tangles with this for hours, but I cannot seem to figure out how to
just read the contents of a file off disk and write it into a binary field in
SQL not using a stored procedure. If I can get that working, I can do
whatever I need, but I can't so far.

Does anyone have a sample of this or an article? There are many articles for
doing this with SPROCS, doing this with SqlClient, not ODBC. I tried just
modifying the objects from an SqlClient example, but no avail.

Appreciate any help on this...
 
P

Paul Clement

¤ 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 code against SQL, but this app will need to
¤ be able to run against any ODBC compliant DB, so I am also not using stored
¤ procedures.
¤

Unfortunately this simply isn't going to be possible. The reason is that most databases use a
proprietary implementation that in all likelihood would not be uniformly supported via ODBC (which
is rather dated technology to begin with).


Paul
~~~~
Microsoft MVP (Visual Basic)
 
G

Guest

Paul,

Thanks for the response, but it's very interesting, you are not the first
person to respond to my question with that answer, but I got it working a few
days ago, inserting a blob into the database using the odbc provider and no
stored procedures, and it's worked on SQL, PostGreSQL, and MySQL so far with
the same code, so I think it is possible.

Thanks anyway...
 
P

Paul Clement

¤ Paul,
¤
¤ Thanks for the response, but it's very interesting, you are not the first
¤ person to respond to my question with that answer, but I got it working a few
¤ days ago, inserting a blob into the database using the odbc provider and no
¤ stored procedures, and it's worked on SQL, PostGreSQL, and MySQL so far with
¤ the same code, so I think it is possible.
¤
¤ Thanks anyway...

Well you said *any* so I was assuming that was more than a few. ;-)

There will be some databases that support the same code but others will not, or they will require a
different data type than binary. I believe that both Oracle, Sybase or Microsoft Access would all
require different solutions.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top