18. juli 2000 - 14:17Der er
5 kommentarer og 1 løsning
Function return value
Hvorfor kan jeg ikke tildele min funktion en værdi??
Function: Function fnAddUser (conn, arrOptions, table, usernames) Dim Query, RS, Query1 If table = "" Then table = "users" End If If usernames = "" Then usernames = "usernames" End If
Query = "SELECT * FROM [" & table & "] WHERE [" & usernames & "] = '" & arrOptions(0,1) & "'" Set RS = Conn.Execute(Query) If NOT RS.EOF OR NOT RS.BOF Then fnAddUser = "username" 'Fejlen kommer ved denne linje! Exit Function End If Set RS = nothing
Query = "INSERT INTO [" & table & "] (" & arrOptions(0,0) If arrOptions(0,2) = "1" Then Query1 = ") VALUES (" & arrOptions(0,1) Else Query1 = ") VALUES ('" & arrOptions(0,1) & "'" End If
If IsArray(arrOptions) Then For i = 1 to ubound(arrOptions) 'Henter data ud af arrOptions og lægger dataen i Query Query = Query & ", " & arrOptions(i,0) If arrOptions(i,2) = "1" Then Query1 = Query1 & ", " & arrOptions(i,1) Else Query1 = Query1 & ", '" & arrOptions(i,1) & "'" End If Next End If
Conn.Execute(Query & Query1 & ")")
fnAddUser = "OK" End Function
Fejl:
Wrong number of arguments or invalid property assignment: 'fnAddUser'
%> <!-- #include file="fnAddUser.asp" --> <% set conn = server.createobject("ADODB.Connection") conn.open "dsn=test" If fnAddUser(conn, arrTest) = "OK" Then 'Fejlen opstår på denne linje! %>juhuu<% Else %>øv<% End If Conn.close set conn = nothing
Det er den der producerer denne fejl:
Wrong number of arguments or invalid property assignment: 'fnAddUser'
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.