Fejl ved migrering til ASP.NET
Jeg har genoplivet et gammelt stykke kode, der virker på den gamle ASP platform.Der kommer nu følgende fejl:
--------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed.
Source Error:
Line 2: dim Str_Name, dbname, Str_Rsname
Line 3:
Line 4: sub OpenConnection(DBPath)
Line 5: if DBPath = "" then
Line 6: response.write "Der Opstod en fejl" & "<BR>"
--------------------
Det er linie 4 den ikke vil godtage.
jeg aner ikke hvad den snakker om... method body ?
-------------
dette er jo blot dens egen compilede version, det som den bliver født med har jeg lagt i en include, og den funktion OpenConnection er en del af det her (her kommer det hele)
-------
<%
dim Str_Name, dbname, Str_Rsname
sub OpenConnection(DBPath)
if DBPath = "" then
response.write "Der Opstod en fejl" & "<BR>"
response.write "Procedure : OpenConnection" & "<BR>"
response.write "Argumenter : Str_Name,DB_Name,DBPath" & "<BR>"
response.write "Beskrivelse : Argumentet DBPath var tomt"
response.end
end if
set Str_Name = server.CreateObject("ADODB.Connection")
Str_Name.open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath(DBPath) & ";PWD=;UID=" 'Access databasen!
if err.number <> 0 then
response.write "Der Opstod en fejl" & "<BR>"
response.write "Procedure : OpenConnection" & "<BR>"
response.write "Argumenter : Str_Name,DB_Name" & "<BR>"
response.write "Fejlkode : " & err.number & "Beskrivelse : " & err.Description & "<BR>"
response.end
end if
on error goto 0
end sub
sub CloseConnection()
if Str_Name = "" then
response.write "Der opstod en fejl da Proceduren CloseConnection havde ventet et argument"
response.end
end if
Str_Name.Close
set Str_Name = nothing
end sub
sub OpenRecordset(Str_Sql)
if Str_Sql = "" then
response.write "En Fejl opstod" & "<BR>"
response.write "Procedure : OpenRecordset" & "<BR>"
response.write "Argument : Str_Sql" & "<BR>"
response.write "Beskrivelse : Havde ikke Ventet et tomt argument" & "<BR>"
response.end
end if
if Str_Name = "" then
response.write "En Fejl opstod" & "<BR>"
response.write "Procedure : OpenRecordset" & "<BR>"
response.write "Argument : Str_Name" & "<BR>"
response.write "Beskrivelse : Havde ikke ventet et Tomt Argument" & "<BR>"
response.end
end if
set Str_Rsname = Str_Name.Execute(Str_Sql)
'if err.number <> 0 then
' response.write "Der Opstod en fejl" & "<BR>"
' response.write "Procedure : OpenRecordSet" & "<BR>"
' response.write "Argumenter : Str_Rsname, Str_Sql, Str_Name" & "<BR>"
' response.write "Fejlkode: " & err.number & "Beskrivelse: " & err.Description
' on error goto 0
' response.end
'end if
on error goto 0
end sub
Sub CloseRecordset()
Str_RSName.close
set Str_RSName = nothing
end sub
sub ExecuteSql(Str_Sql)
if Str_Sql = "" then
response.write "En fejl opstod" & "<BR>"
response.write "Procedure : ExecuteSql" & "<BR>"
response.write "Argument : Str_Sql" & "<BR>"
response.write "Beskrivelse : Proceduren havde ikke ventet et Tomt Argument" & "<BR>"
response.end
end if
if Str_Name = "" then
response.write "En fejl opstod" & "<BR>"
response.write "Procedure : ExecuteSql" & "<BR>"
response.write "Argument : Str_Name" & "<BR>"
response.write "Beskrivelse : Proceduren havde ikke ventet et Tomt Argument" & "<BR>"
response.end
end if
on error resume next
Str_Name.Execute Str_Sql
if err.number <> 0 then
response.write "Der Opstod en fejl" & "<BR>"
response.write "Procedure : ExecuteSql" & "<BR>"
response.write "Argumenter : Str_Sql, Str_Name" & "<BR>"
response.write "Fejlkode: " & err.number & "Beskrivelse: " & err.Description
on error goto 0
response.end
end if
end sub
%>