2013-11-01 3 views
2

그래서 웹 사이트에 기사 편집 기능을 추가하려고하는데 문제가 발생했습니다. 다음과 같은 오류는 다음과 같습니다이 SQL 오류를 발견 할 수 있습니까?

Microsoft Jet 데이터베이스 엔진 오류 하나 개 이상의 필수 매개 변수에 주어진 '80040e10'

값 없음.

/courses/benv/2410/2013s2/3420384/assign4/edit.asp 오류 코드가 아래에 단계 3에서 발생하는 130

라인. 특히 Suburbtable 업데이트 명령 직후입니다.

나는 시도 인쇄 문을 추가하고 디버그 다음과 같은 내놓았다 : 아래

update SuburbTable set suburb='Kensington', postcode=2033 where projectsTable.ID= 56 

코드. 도움말 감사.

<% option explicit %> 
<html> 
<head> 
    <link href="normalize.css" rel="stylesheet" type="text/css"> 
    <link rel="stylesheet" type-"text/css" href="960_12_col.css"> 
    <link rel="stylesheet" type-"text/css" href="style.css"> 
</head> 
<body> 
<!--#include file="dbconn.asp"--> 
<!--#include file="header.asp"--> 

    <div class="content"> 

<div class="content-inner container_12"> 

    <div class="wrapper prefix_2 grid_8 suffix_2"> 
<% 

if Session("username")="" then 
    Response.Redirect("Login.asp") 
end if 

    dim stage, SQL, info 
    stage = request.form("stage") 
    if stage = "" then stage=1 

    '------------------------------------------------------------------ 
    if stage = 1 then 
    '------------------------------------------------------------------ 

     response.write "<form action=""edit.asp"" method=""post"">" &_ 
        "<input type=""hidden"" name=""stage"" value=""2"">" 


    '--- create a radio-button list of the posts 
    '      0    1     
    SQL="select ProjectsTable.ID, ProjectName from ProjectsTable order by Created" 
    set info=conn.execute(SQL) 

    '-- Loop through the recordset to make each entry in the list. 
    do while not info.eof 

     response.write "<label id=""Select""for=""radio""></label>"&_ 
        "<input id=""radio""type=""radio"" name=""change"" "&_ 
        "value="""&info(0)&""">"&info(1)&"<br>"&chr(13) 
    info.movenext 
    loop 

    response.write "<input class=""button"" type=""submit"" value=""Select!"">" &_ 
       "</form>" 


    '------------------------------------------------------------------ 
    elseif stage = 2 then 
    '------------------------------------------------------------------ 

    dim record_num 
    record_num=Request.Form("change") 
    if record_num="" then response.redirect "?pg=change" 

    '      0    1    2   3  4    5       
    SQL="SELECT ProjectsTable.ID, ProjectName, Description, suburb, postcode, pictureURL"&_ 
     " FROM ProjectsTable, SuburbTable, CategoryTable"&_ 
     " WHERE ProjectsTable.ID= "&record_num &_ 
     " AND suburbtable.id = SuburbNum AND categorytable.ID = categoryNum" 

    set info=conn.execute(SQL) 
%> 
     <form action="edit.asp" method="post"> 
     <input type="hidden" name="stage" value="3"> 
     <input type="hidden" name="ProjectsTable.ID" value="<% =record_num %>"> 
     <label for="title">Title</label> 
     <input id="title" type="text" name="title" value="<% =info(1) %>"><br> 
     <label for="image">Image URL</label> 
     <input id="image" type="text" name="image" value="<% = info(5) %>"><br> 
     <label for="post">Post</label> 
     <textarea id="post" name="post"><%=info(2) %></textarea><br> 
     <label for="suburb">Suburb</label> 
      <input id="suburb" type="text" name="suburb" value="<% =info(3) %>"><br> 
     <label for="postcode">Postcode</label> 
      <input id="postcode" type="text" name="postcode" value="<% =info(4) %>"><br> 

<% 
'     0    1 
sql = "select categorytable.ID, category "&_ 
     "from categorytable "&_ 
     "order by category " 

     set info=conn.execute(SQL) 

%> 
     <label for="category">Category</label> 
      <select name="category"> 
     <% 
     do until info.eof 
     response.write "<option value=""" & info(0) & """>" & info(1) & "</option>" 
     info.movenext 
     loop 

     %> 
     </select> <br> 
     <input id="edit" class="button" type="submit" value="Edit"> 
     </form> 
<% 
    '------------------------------------------------------------------ 
    elseif stage = 3 then 
    '------------------------------------------------------------------ 

    dim title, post, post_id, picture, suburb, postcode, category, u, uid, s_info 

    title=Request.Form("title") 
    post=Request.Form("post") 
    u=Session("username") 
    post_id=Request.Form("ProjectsTable.ID") 
    picture=Request.Form("image") 
    suburb=Request.Form("suburb") 
    postcode=Request.Form("postcode") 
    category=Request.Form("category") 


     '    0  
    sql = "select usertable.id "&_ 
     "from usertable where username='"&u&"'" 
     set info=conn.execute(sql) 
     uid = info(0) 

    sql="update SuburbTable set suburb='"& suburb & "', postcode=" & postcode & " "&_ 
     "where projectsTable.ID= "&post_id 
     response.write(SQL) 
     conn.execute sql 

'    0  
    sql = "select id from suburbtable where suburb='" & suburb & "' and postcode=" & postcode & " " 
     set s_info=conn.execute(sql) 

    sql="update projectsTable set projectName='"& title & "', Description='" & post & "', "&_ 
     "usernum="& uid & ", categorynum="& category & ", pictureURL='"& picture & "', suburbNum="& s_info(0) & " "&_ 
     "where projectsTable.ID= "&post_id 

     conn.execute sql 

     response.write "<p>Post edited.</p>" 



    '------------------------------------------------------------------ 
    end if ' stage 
    '------------------------------------------------------------------ 

    if stage=3 then 
    response.write "<a href=""default.asp"">Show Posts</a>" 

    end if 
    conn.close 
%> 

    </div> 

</div> 

</div> 


<!--#include file="footer.asp"--> 
</body> 
</html> 
+0

당신이 열 이름 (또는 존재하지 않는 열)에 오타가있을 때 당신은 또한 귀하의 회신에 대한 –

답변

2

당신은 더 projectsTable 표는이 성명에서이없는 당신의 UPDATE에 오류가 있습니다.

update SuburbTable set suburb='Kensington', postcode=2033 
where projectsTable_ID= 56 

UPD : 나는 projectsTable_ID (???) 그래서 projectsTable.ID

그것은해야 보입니다되지 같은 이름을 가진 SuburbTable에서 Fild입니다 추측

I'don't 아는 방법 테이블 서로 연결되지만 suburbtable.id = projectsTable.SuburbNum 필드를 통해 추측합니다. 이 경우에는해야 보이는 같은 :

update SuburbTable set suburb='Kensington', postcode=2033 
where Id=(SELECT SuburbNum from projectsTable where projectsTable.ID= 56) 
+0

덕분에 그 "매개 변수"오류가 발생합니다. ProjectsTable.ID는 프로젝트 테이블에서 왔지만 분명히 잘못 처리했습니다. 나는 유일한 ID로 포스트를위한 교외와 우편 번호를 업데이트하고 싶다. projectsTable_ID라는 필드가 없습니다. 이 where 절을 추가하기 전에 모든 게시물을 업데이트하고있었습니다. 올바른 방향으로 나를 가리키는 어떤 아이디어? – chap

+0

@AndrewChappell 업데이트 된 답변을 확인하십시오. – valex

관련 문제