Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, can u help me to check what

Status
Not open for further replies.

hoog

Technical User
Feb 28, 2007
8
0
0
US
Hello, can u help me to check what is wrong with it?

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'from'.

/mailpwd1.asp, line 28



<%

Dim DataConn, ConnString
Dim SQL, Email, oRs
Dim Email2, password2
Dim MyMail

Email=Request.Form (&quot;text1&quot;)

Set DataConn = Server.CreateObject(&quot;ADODB.Connection&quot;)

ConnString=&quot;driver={sql server};server=CON7; database=user;DSN=localserver;PWD=sa;UID=sa;&quot;
DataConn.Open ConnString

SQL=&quot;select * from password, email from user where email='&quot; & Email & &quot;'&quot;

Set oRs= Server.CreateObject (&quot;ADODB.recordset&quot;)
oRs.Open SQL, DataConn, 3

If oRs.EOF Then
response.write &quot;<html><head><body bgcolor='#000000' text='#ffff00'><center>&quot;
Response.Write &quot;<font face='verdana' size='+2'><p>&quot;
Response.Write &quot;No records found:<p> Use the browser's back button to go back and try again&quot;
Response.Write &quot;</font></body></html>&quot;
Response.End
end if

Email2=oRs(&quot;Email&quot;)
password2=oRs(&quot;password&quot;)

oRs.Close
Set oRs=nothing

Set MyMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

MyMail.From=&quot;yourname@123.com&quot;
MyMail.To = Email2
MyMail.Subject =&quot;Your Password&quot;
MyMail.Body= password2

MyMail.Send
Set MyMail= nothing
%>
X-)
 
SQL=&quot;select * from password, email from user where email='&quot; & Email & &quot;'&quot;

is malformed SQL syntax.

you have two from clauses there. Maybe this is what you're looking for?

SQL=&quot;select password, email from user where email='&quot; & Email & &quot;'&quot;
penny.gif
penny.gif
 
It has the same error when i do the above statment SQL=&quot;select password, email from user where email='&quot; & Email & &quot;'&quot; .So what could the problem lies? Or the problem lies in oRs.Open SQL, DataConn, 3 .
 
No, it's your SQL for sure.

Try surrounding the name of your table in brackets. user might be a reserved word:

SQL=&quot;select password, email from [user] where email='&quot; & Email & &quot;'&quot;
penny.gif
penny.gif
 
try



SQL=&quot;SELECT * FROM user where email='&quot; & Email & &quot;'&quot;

may work easier
 
SELECT *

is not the best habit to get into... it's always better to only select just the columns you need. It will make your applications run faster, since you're passing less data around.

We're all guilty of it sometimes, but it won't &quot;work easier&quot; than selecting just the columns you want.
penny.gif
penny.gif
 
i just tested this, and link9 is right, it is a problem with 'user' being a reserved word. surrounding it in brackets fixed the problem. 'password' is also a reserved word and could cause an error about 'invalid syntax in insert statement' when trying to update the table. to get around these problems, we always add a prefix to table field names so that we don't end up with reserved words, and changing the table name to 'users' instead of 'user' also solves this current problem without having to remember the brackets.... avoiding reserved words seems the best solution to me.

;-)


 
Here's a database tip I use in all my projects: Give each table a 3 or 4 character code, then prefix all field names in that table with the code.

For example, your &quot;user&quot; table might have a 3 letter code of &quot;USR&quot; so the fields would be named USR_Name, USR_Password, USR_ExpiryDate, etc.

It helps when joining tables too, since you won't need to use the table name and field name to reference a field. And even if you only know a field name, you always know what table it came from. I think this is called Nyulian notation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top