Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to escape binary data in sql server ?

Author  Topic 

rogerwux
Starting Member

5 Posts

Posted - 2008-05-12 : 09:15:17
Hi there,
I was just wondering is anybody knows how to escape binary
data before inserting into sql sever ?

I have a BYTE * pointer to the data of image and gonna to
escape before format as string insert into database,

thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-12 : 10:15:01
Which datatype are you goinf to use to store the pointer?
You know you can use VARBINARY or BINARY datatype?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rogerwux
Starting Member

5 Posts

Posted - 2008-05-12 : 10:42:35
Yes, I use varbinary(max) to store the data, but i am not sure how to
escape in vs2005 as I have already got the pointer the image, any
advice, cheers
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-12 : 10:48:10
You only need a BINARY(8) to store a pointer from Visual Studio in the database.
Use parametrized query and use BINARY as parameter datatype.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rogerwux
Starting Member

5 Posts

Posted - 2008-05-12 : 10:56:46
quote:
Originally posted by Peso

You only need a BINARY(8) to store a pointer from Visual Studio in the database.
Use parametrized query and use BINARY as parameter datatype.



E 12°55'05.25"
N 56°04'39.16"



The point is that my pointer (BYTE *) to the data of image/jpg
which is not small, some may larger than 1M so I use varbinary(max)
intentionally to store the image data into the database after
format as string, um
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-12 : 11:13:42
If you are going to store the complete image, use image datatype.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rogerwux
Starting Member

5 Posts

Posted - 2008-05-12 : 11:13:52
Say, I have BYTE *data; pointer to data of image/jpg and
how to escape it ???

I have to escape it before storing it into database using the following fomrat:
sprintf ((char*)query_str, "INSERT INTO [dbo].[img_table] (id, img_data) VALUES ('%d', '%s')", newId, escape_str);
both query_str and escape_str defined as BYTE *;

any ideas, thanks
Go to Top of Page

rogerwux
Starting Member

5 Posts

Posted - 2008-05-12 : 11:18:28
quote:
Originally posted by Peso

If you are going to store the complete image, use image datatype.



E 12°55'05.25"
N 56°04'39.16"




Um...Yes, a easy way to store the image is to directly store
into database, but based upon our requirements we have to
decode and encrypte the jpg data before storing into database
so basically i got the pointer to the encrypted data and then
try to format as string before inserting into db. so my question
is how to escape in such situation, um.

Also I figured out that if using mysql there is mysql_real_escape_string does the escape job, but i havt found
there is any kind of functions odbc api provides to do the escape job
and I was wondering is anybody know how to do the escape job, and
i have to do that in vs2005... um
Go to Top of Page
   

- Advertisement -