09/10/2018, 17:25
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
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
Bài liên quan
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ẻ.
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.
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.