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

Getting the text encoded value of a jpg file...

Hi:

I want to set a default value of a varbinary(max) column in SQL Server. The
reason is my application databinds to a varbinary(max) column to display
pictures, and if there is no picture when record is created, I would like it
to default to a common picture. To do this, I will need text encoded
equivalent of binary file so I can paste it in as a column default. How do
I do this?

Thanks,
Charlie
Feb 8 '07 #1
3 1467
do a hex dump of the image. then use this syntax:

insert table (@id, 0xfffffffffff)


Charlie@CBFC wrote:
Hi:

I want to set a default value of a varbinary(max) column in SQL Server. The
reason is my application databinds to a varbinary(max) column to display
pictures, and if there is no picture when record is created, I would like it
to default to a common picture. To do this, I will need text encoded
equivalent of binary file so I can paste it in as a column default. How do
I do this?

Thanks,
Charlie

Feb 8 '07 #2
On Feb 8, 7:47 am, "Charlie@CBFC" <char...@cbfconsulting.comwrote:
Hi:

I want to set a default value of a varbinary(max) column in SQL Server. The
reason is my application databinds to a varbinary(max) column to display
pictures, and if there is no picture when record is created, I would like it
to default to a common picture. To do this, I will need text encoded
equivalent of binary file so I can paste it in as a column default. How do
I do this?

Thanks,
Charlie
Why don't you upload the default file to your database and have it as
ID of 0. Then in control the insert of the default image in your SP,
if the jpg is dbnull then do an insert of the default file you have
you in your database.

if( @filedata is null)

select @imagedata=data from files where id=0
insert into files(imagedata) values(@imagedata)

- Manit
http://www.acriticsreview.com

Feb 9 '07 #3
Thanks guys. I downloaded a hex editor to get at the code.

Used it in SP. Works great.

"bruce barker" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
do a hex dump of the image. then use this syntax:

insert table (@id, 0xfffffffffff)


Charlie@CBFC wrote:
>Hi:

I want to set a default value of a varbinary(max) column in SQL Server.
The reason is my application databinds to a varbinary(max) column to
display pictures, and if there is no picture when record is created, I
would like it to default to a common picture. To do this, I will need
text encoded equivalent of binary file so I can paste it in as a column
default. How do I do this?

Thanks,
Charlie

Feb 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dan glenn | last post by:
hi. I want to code a 'preview' function into a guestbook entry page. I can do it with a button that posts, bringing up a whole new page showing a preview of what has been entered, and then the user...
9
by: Ksenia Marasanova | last post by:
Hi, I have a little problem with encoding. Was hoping maybe anyone can help me to solve it. There is some amount of data in a database (PG) that must be inserted into Excel sheet and emailed....
0
by: Matthew Simoneau | last post by:
I'm trying to figure out how to HTML encode shift_jis text and put it into an attribute. Starting with this XML-file with characters encoded in shift_jis <?xml version="1.0"...
5
by: Mike Murray | last post by:
Hi I have the following issue. I have a character that is return by a SQL Server database "É" to be precise, the issue is that when I store character in a .net string variable my understanding...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
0
by: ptraj | last post by:
Dear ppls, I'm doing a small project to extract all messages from outlook by Visual Basic 6.0 and write them into a file(in MBOX format). While accessing messages i able to get headers, body,...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
1
by: FLX | last post by:
Hello, I'm trying to scrape daily titles from http://www.doopes.com/?cat=35444&lang=1&num=5&mode=0&from=2007-09-04&to=2007-09-04&exc=&inc=&opt=0 But i'm getting lost using preg_match. Can someone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

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.