PDA

View Full Version : writing a unicode file


esthera
07-11-2005, 02:40 PM
I am trying to write contents form a db into an excel --
it works but when I have hebrew that I am pulling from the db then it gives me an error. I assume that this is because the server that I am on does not support hebrew -- is there anyway around this?

reubenb
07-13-2005, 02:17 AM
I've done this with Hebrew before...
Show me your code?

esthera
07-13-2005, 05:51 AM
sub outputexcel(sql)
'response.write sql
randomize
nRandom = (100-1)*Rnd+1
fileExcel =monthname(month(date)) & cstr(year(date)) & "_" & CStr(nRandom) & ".xls"
filePath= Server.mapPath("personneladmin.asp")
filepath=mid(filepath,1,len(filepath)-18)
'response.write "filepath:" & filepath & "<br>"
filename=filePath & "excelfiles\" & fileExcel
'response.write filename
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = fs.CreateTextFile(filename, True)

Set rs = objconn.Execute(sql)

strLine="<table><tr>" 'Initialize the variable for storing the filednames

For each x in rs.fields
strLine= strLine & "<td>" & x.name & "</td>"
Next
strline=strline&"</tr>"
MyFile.writeline strLine

Do while Not rs.EOF
strLine="<tr>"
for each x in rs.Fields
cell=x.value
strLine= strLine & "<td>" & cell & "</td>"
next
strline=strline & "</tr>"
MyFile.writeline strLine
rs.MoveNext
Loop
myfile.writeline "</table>"
MyFile.Close
Set MyFile=Nothing
Set fs=Nothing

link="<A HREF=excelfiles/" & fileExcel & " class=adminmenu target=_new>Click Here to Open Excel</a>"
Response.write "<br>Excel File Created<br><br>" & link


end sub

It errors me on teh line MyFile.writeline strLine --- meaning it writes the headings of the tables but can't write the first line for some reason.

reubenb
07-13-2005, 05:57 AM
What is the error exactly?
And, what should the output be?

esthera
07-13-2005, 06:37 AM
error is:

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument



output is a hebrew name, email, phone

when I use the same sub for english entries I get no errors.

reubenb
07-13-2005, 08:11 AM
This error means that (usually) you passed an invalid parameter in your procedure call. Sometimes, This could be also be because the parameter was out of range, or contained invalid data. Alternately, you may have invoked a procedure at an unexpected time.

I am expecting that since most databases and languages are in English - it is "invalid" data.

I doubt it is because Hebrew [and other language-support] is not installed on the server environment because it doesn't read the data as such.

Are they entering their data through a rich text editor or through a normal form?

I just tried entering Hebrew data into a database and it worked (and viewed it through ASP) so I think it has something to do with the Excel thing.

Can you show me your entire code (and where you call the sub)?

Thanks, Hope I can help.

esthera
07-13-2005, 08:17 AM
the reason i say it's hebrew is i have the same table one with english data and one with hebrwe

I say select name,email,phone from applicants and send this to the output(sql) sub and it works in the english one but in the hebrew one returns the errr.

what else can it be?