Diễn Đàn Tin Học

Hiển thị kết quả từ 1 đến 5 / 5
  1. #1
    Tham gia
    16-07-2002
    Location
    Ha Noi
    Bài viết
    1,281
    Like
    0
    Thanked 0 Times in 0 Posts

    Lỗi không hiểu nguyên nhân????

    Mong mọi người chỉ giúp. File CSDL có một bảng tên là Counter như sau:
    username : text(50)
    email : text(50)
    password : text(50)
    counter : Long Integer

    File add.asp như sau:
    <%
    Response.Buffer = True
    Response.Write "<HTML><BODY>"
    If IsEmpty(Request.Form ("username")) OR IsEmpty(Request.Form ("password")) OR IsEmpty(Request.Form ("email")) then
    Response.Write "You have to fill all fields"
    else
    Dim username, password, email
    username = Request.Form ("username")
    password = Request.Form ("password")
    email = Request.Form ("email")
    if (username="") or (password="") or (email="") then
    Response.write "Not allow blank field"
    else
    Dim strSQL, myConn, rsCounter
    strSql = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath ("counter.mdb")
    Set myConn = Server.CreateObject ("ADODB.Connection")
    myConn.Open strSql
    strSql = "SELECT * FROM Counter WHERE username='" & username & "';"
    Set rsCounter = MyConn.Execute(strSql)
    if rsCounter.EOF <> True then
    rsCounter.close
    Set rsCounter = Nothing
    myConn.Close
    Set myconn = Nothing
    Response.Write "Username is existed"
    else
    rsCounter.Close
    Set rsCounter = Nothing
    strSQL = "INSERT INTO Counter (username, password, counter, email) VALUES ('" & username & "', '" & password & "', 0, '" & email & "');"
    myConn.Execute strSql
    myConn.Close
    Set myConn = Nothing
    Response.Write "You have been registerd!<br>o"
    end if
    end if
    end if
    Response.Write "<br><a href=""default.asp"">Back to Register</a></BODY></HTML>"
    %>

    Lỗi mà IE thông báo:
    · Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error in FROM clause.
    /counter/Add.asp, line 19
    · Browser Type:
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; NetCaptor 7.0.1)
    · Page:
    POST 31 bytes to /counter/Add.asp
    · POST Data:
    username=23&password=2&email=23
    Quote Quote

  2. #2
    Tham gia
    03-08-2002
    Location
    HN
    Bài viết
    22
    Like
    0
    Thanked 0 Times in 0 Posts
    hà hà, trả ơn bạn nhé, về đổi tên bảng đi là được ngay, tôi đã thử rồi, chỉ cần thay tên là được trong access nó không chấp nhận một số tên bảng có tên như thế.
    ví dụ tên bảng là "user" hay "group" hay "counter" là nó báo ngay lỗi này. "Syntax error in FROM clause."
    bạn nên đặt tên bảng theo chuẩn lập trình như thế đỡ bị loạn hơn, ví dụ prog của bạn về product thì bạn nên đặt là "prod_counter" chẳng hạn. chúc vui vẻ.

  3. #3
    Tham gia
    03-08-2002
    Location
    HN
    Bài viết
    22
    Like
    0
    Thanked 0 Times in 0 Posts
    ----------------------------------------------
    if rsCounter.EOF <> True then
    rsCounter.close
    Set rsCounter = Nothing
    myConn.Close
    Set myconn = Nothing
    Response.Write "Username is existed"
    else
    rsCounter.Close
    Set rsCounter = Nothing
    strSQL = "INSERT INTO Counter (username, password, counter, email) VALUES ('" & username & "', '" & password & "', 0, '" & email & "');"
    myConn.Execute strSql
    myConn.Close
    Set myConn = Nothing
    ----------------------------------
    bạn không cần đóng connection quá sớm như thế đâu, recỏdset thì có thể đóng nhưng connection thì bạn nên làm thành một biến tổng thể để liên kết toàn web site của bạn, như thế sẽ gọn hơn nhiều.

  4. #4
    Tham gia
    10-08-2002
    Location
    Dong Nai
    Bài viết
    2
    Like
    0
    Thanked 0 Times in 0 Posts
    Neu ban khong muon doi ten Table the dat no vao trong dau []

  5. #5
    Tham gia
    16-07-2002
    Location
    Ha Noi
    Bài viết
    1,281
    Like
    0
    Thanked 0 Times in 0 Posts
    Yes, mình đã sửa được rồi. Cho vào trong []
    Hi, đóng luôn connect cũng được. đỡ tốn tài nguyên cho server. Nó có cơ chế pool mà, đâu có chậm. Dùng xong thì giải phóng bộ nhớ cho application khác.

Bookmarks

Quy định

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •