If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Can Anyone Help me?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-04, 02:36
ekawit ekawit is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
Can Anyone Help me?

Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument
/ase/csspss_editE.asp, line 230
************************************************** *********
Dim UploadRequest,RequestBin,dte, time, CompanyName,ContactName,CompanyAddress,Position,Ca tegory,Tel,map
Set UploadRequest = CreateObject("Scripting.Dictionary")
filepath=Server.MapPath("images/map")
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin
dte = UploadRequest.Item("dte").Item("Value")
eTime = UploadRequest.Item("tim").Item("Value")
CompanyName = UploadRequest.Item("CompanyName").Item("Value")
ContactName = UploadRequest.Item("ContactName").Item("Value")
Position = UploadRequest.Item("Position").Item("Value")
Category = UploadRequest.Item("cat").Item("Value")
CompanyAddress = UploadRequest.Item("CompanyAddress").Item("Value")
Tel = UploadRequest.Item("Tel").Item("Value")
filepathname = UploadRequest.Item("map").Item("FileName")
map = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
mapvalue = UploadRequest.Item("map").Item("Value")

Sub uploadimage(imgvalue,imgname)
if lenB(imgvalue) = 0 then
response.write "<b>Can not Upload " & "&auml;&Aacute;&egrave;&Aacute;&Otilde;&auml;&ique st;&Aring;&igrave;&sup1;&Otilde;&eacute; / &auml;&iquest;&Aring;&igrave;&Aacute;&Otilde;&cent ;&sup1;&Ograve;&acute;&agrave;&raquo;&ccedil;&sup1 ;&Egrave;&Ugrave;&sup1;&Acirc;&igrave; &curren;&Aring;&Ocirc;&iexcl; Back </b>"
response.end
end if
limitSize = 1024 * 1024
if lenB(imgvalue) > limitSize then
response.write "<b>File &atilde;&Euml;­&egrave;&agrave;&iexcl;&Ocirc;&sup1 ; " & FormatNumber(limitSize / 1024) & " KB &curren;&Aring;&Ocirc;&iexcl; Back &iexcl;&Aring;&Ntilde;&ordm;&auml;&raquo;&agrave;& Aring;&times;&Iacute;&iexcl;&atilde;&Euml;&Aacute; &egrave;"
response.end
end if

Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set fileObj = ScriptObject.CreateTextFile(filepath & "/" & imgname)
For i = 1 to LenB(imgvalue)
fileObj.Write chr(AscB(MidB(imgvalue,i,1))) >>>>LINE230
Next
fileObj.Close
End Sub
Call uploadimage(mapvalue,map)

ErrMsg = ""
if Request.Form("dteDisplay") = "" then ErrMsg = "กรุณาใสวันที่<br>"
if Request.Form("Tim") = "" then ErrMsg=ErrMsg & "กรุณาใส่เวลา<br>"
if Request.Form("CompanyName") = "" then ErrMsg=ErrMsg & "กรุณาใส่ชื่อบริษัท <br>"
if Request.Form("Contactname") = "" then ErrMsg=ErrMsg & "กรุณาใส่ชื่อของผู้ติดต่อ<br>"
if Request.Form("Position") = "" then ErrMsg=ErrMsg & "กรุณาใส่ตำแหน่งงานของผู้ติดต่อ <br>"
if Request.Form("CompanyAddress") = "" then ErrMsg=ErrMsg & "กรุณาใส่ที่อยู่ <br>"
if Request.Form("Tel") = "" then ErrMsg=ErrMsg & "กรุณาใส่เบอร์โทรศัพท์ <br>"
if Request.Form("map") = "" then ErrMsg=ErrMsg & "กรุณาใส่รูปแผ่นที่<br>"

if len(ErrMsg) > 0 then
Response.Write "<tr><td><div class=heading2>There were problems with your edits:<br></div>"
Response.Write "<div class=heading3>" & ErrMsg & "</div>"
Response.Write "<table border='0' cellSpacing=4 align=right valign=top style='margin-right:-4;'"
Response.Write "<tr height=22><a href='javascript:history.go(-1)'><td id='MyButton' width=60 class=btn>Back</td></a>"
Response.Write "</tr></table></td></tr>"
Else
rs.Open "Csspss", my_conn, 2, 3
rs.AddNew
rs("dte") = Request.Form("dte")
rs("eTime") = Request.Form("tim")
rs("CompanyName") = Request.Form("CompanyName")
rs("ContactName") = Request.Form("ContactName")
rs("Position") = Request.Form("Position")
rs("Category") = Request.Form("cat")
rs("CompanyAddress") = Request.Form("CompanyAddress")
rs("Tel") = Request.Form("Tel")
rs("map") = Request.Form("map")
rs.Update
Response.Write "<div class=heading3>Added Customer</div>"
End If

Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Conte nt-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filen ame="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
If PosFile<>0 AND (PosFile<PosBound) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add "Value" , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),Requ estBin,boundary)
Loop

End Sub

Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
************************************************** ********
what's wrong at LINE230?
Reply With Quote
  #2 (permalink)  
Old 04-05-04, 03:17
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
I suspect your problem is in your MidB call. Check the value of i.

If that bit all seems right split this line out into a series of lines (just for debugging) so you can determine exactly what function is failing.
Reply With Quote
  #3 (permalink)  
Old 04-05-04, 18:27
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
The syntax is object.Write(string).

I'm not sure if you can use object.Write chr(Byte). Can you tell us what do you want to do with fileObj.Write chr(AscB(MidB(imgvalue,i,1)))?
Reply With Quote
  #4 (permalink)  
Old 04-05-04, 19:03
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
fileObj.Write chr(AscB(MidB(imgvalue,i,1)))?

what he is doing with the above line is grabbing a single byte, getting the AscII code for it then converting that code to a character using the chr function.

I don't know if that is a legit use of the functions but in theory that is what is trying to be done (I think).
Reply With Quote
  #5 (permalink)  
Old 04-05-04, 20:50
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Why don't you use

fileObj.Write imgvalue

instead of

For i = 1 to LenB(imgvalue)
fileObj.Write chr(AscB(MidB(imgvalue,i,1)))
Next

?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On