Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert a Word file in SQL Server
Message
De
27/08/2004 20:47:10
Peter Wagner
Point Informática Ltda.
Limeira, Brésil
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00936777
Message ID:
00937235
Vues:
28
Sergey,
Thanks for the link, but I have a question about it.
In the link Vlad says...:
Text field on SQL Server is not good to store binary data because it is not 
reliable and often SQL Server corrupts binary data in text field
And
When binary data passed to SQL Server, they're encoded to match the 
format required for SELECT statement in T-SQL.
In my test I'm doing this:
* To Store a Word Doc in SQL Server
***********************************
CLEAR
=SQLDISCONNECT(0)
x = GETFILE("Doc","Word File")
Y = FILETOSTR(x)
cStringConnect =("DRIVER={SQL Server};SERVER=BOSS700;UID=xxx;PWD=xxx;DATABASE=Atuante2")
nID = SQLSTRINGCONNECT(cStringConnect)
csql = "INSERT INTO teste1(texto) Values(?Y)"

a = SQLEXEC(nID,csql)
IF a < 1
	=AERROR(my_erro)
	DISPLAY MEMORY LIKE my_erro
ELSE
	WAIT WINDOW "OK" TIMEOUT 1
ENDIF

* To Get the Data of a Word Doc from SQL Server
***********************************************
cStringConnect =("DRIVER={SQL Server};SERVER=BOSS700;UID=xxx;PWD=xxx;DATABASE=Atuante2")
nID = SQLSTRINGCONNECT(cStringConnect)
csql = "SELECT * FROM teste1 Where codigo > 2"
a = SQLEXEC(nID,csql,"Cur_test")
IF a < 1
	=AERROR(my_erro)
	DISPLAY MEMORY LIKE my_erro
ELSE
	WAIT WINDOW "OK" TIMEOUT 1
	SELECT("Cur_test")
	=STRTOFILE(Cur_test.texto,"AMD2.DOC")
ENDIF
I made some test and the code works fine with SQL Server, and I'm able to get the value from a Text field in a SQL Table, and transform it into a Word document again without problems.
My question is: Did You had any problem storing data in Text fields ?
I'm afraid that it works fine now but later it brings me in trouble because I missed something.
I wasnt able to see any problem like the one described by Vlad.

TIA

[ ],s
Peter

>Peter,
>
>Take a look at How to work with Image field type on SQL Server (binary data)? FAQ #7995
>
>>I making some test to insert a DOC file into a SQL Server Table, but havent success in doing it!
>>Any Idea or advice how to do it ?
>>I tried with Image, Ntext, text field in SQL Server, and it didnt work also.
>>
><snip>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform