Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Select Statement


Message #1 by Leo Clayton <claytonl@z...> on Wed, 22 Nov 2000 15:10:06 -0500
--=====================_454987146==_.ALT

Content-Type: text/plain; charset="us-ascii"; format=flowed



Can someone tell me what is wrong with this Select statement that causes 

the following error:



Microsoft VBScript compilation error '800a0401'



Expected end of statement



/EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line 25



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = Session('"IDNumber"');"

---------------------------------------------------------------------------- 

-----------------------------------^



I want to SELECT the record that has an IDNumber that matches the 

Session("IDNumber") and if it does I want to write the output in a table 

format.  Here is my code:



<% @LANGUAGE = "VBSCRIPT" %>



<% Response.Buffer = True %>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>

<HEAD>



<TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

</HEAD>



<BODY BGCOLOR="FFFF80">

<CENTER>

<H1>EMPLOYEE MASTER DATABASE<BR>

UPDATING THE EMPLOYEE TABLE</H1>

</CENTER>



<%

Response.Write ("The File Selected To Be Updated is ")

Response.Write (Request.Form("TableToBeUpdated"))

%>



<%

If Request.Form("TableToBeUpdated") = "Employee" Then

         strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = 

Session('"IDNumber"');"

         Set DbObj = Server.CreateObject("ADODB.CONNECTION")

         DbObj.Open "DSN=EmployeeMaster"

         Set oRs = DbObj.Execute(strSQL)

<TABLE BORDER=3>

<TR>

<TD>    <% =oRs.Fields("FirstName").Value %>    </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("LastName").Value %>    </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("Title").Value %>       </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("Education").Value %>   </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("JobHistory").Value %>  </TD>

</TR>

</Table>



'       Response.Redirect "SelectFieldsToUpdate.asp"

'Else

'Response.Redirect "UpdateEmployeeSkillsTable.asp"

'End If

End If

%>



</BODY>

</HTML>




















Message #2 by "Ken Schaefer" <ken@a...> on Thu, 23 Nov 2000 11:27:06 +1100
You are creating a string and allocating that to a variable call strSQL.

In this string you are writing session("IDNumber") as literal text.

You can see thig by doing the following:



Response.Write(strSQL)



What you need to do is this:



strSQL = "SELECT * "

strSQL = strSQL & "FROM EmployeeTable "

strSQL = strSQL & "WHERE IDNumber = " & Session("IDNumber")



That said, don't use SELECT *

http://www.adopenstatic.com/faq/selectstarisbad.asp



Cheers

Ken





----- Original Message -----

From: "Leo Clayton" <claytonl@z...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, November 23, 2000 7:10 AM

Subject: [asp_databases] Select Statement





> Can someone tell me what is wrong with this Select statement that causes

> the following error:

>

> Microsoft VBScript compilation error '800a0401'

>

> Expected end of statement

>

> /EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line 25

>

> strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber 

Session('"IDNumber"');"

> --------------------------------------------------------------------------

--

> -----------------------------------^

>

> I want to SELECT the record that has an IDNumber that matches the

> Session("IDNumber") and if it does I want to write the output in a table

> format.  Here is my code:

>

> <% @LANGUAGE = "VBSCRIPT" %>

>

> <% Response.Buffer = True %>

>

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

> <HTML>

> <HEAD>

>

> <TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

> </HEAD>

>

> <BODY BGCOLOR="FFFF80">

> <CENTER>

> <H1>EMPLOYEE MASTER DATABASE<BR>

> UPDATING THE EMPLOYEE TABLE</H1>

> </CENTER>

>

> <%

> Response.Write ("The File Selected To Be Updated is ")

> Response.Write (Request.Form("TableToBeUpdated"))

> %>

>

> <%

> If Request.Form("TableToBeUpdated") = "Employee" Then

>          strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber 

> Session('"IDNumber"');"

>          Set DbObj = Server.CreateObject("ADODB.CONNECTION")

>          DbObj.Open "DSN=EmployeeMaster"

>          Set oRs = DbObj.Execute(strSQL)

> <TABLE BORDER=3>

> <TR>

> <TD>    <% =oRs.Fields("FirstName").Value %>    </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("LastName").Value %>    </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("Title").Value %>       </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("Education").Value %>   </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("JobHistory").Value %>  </TD>

> </TR>

> </Table>

>

> '       Response.Redirect "SelectFieldsToUpdate.asp"

> 'Else

> 'Response.Redirect "UpdateEmployeeSkillsTable.asp"

> 'End If

> End If

> %>

>

>

> </BODY>

> </HTML>

>

>

>

>

>

>

>

>

>

>



Message #3 by "Dallas Martin" <dmartin@z...> on Wed, 22 Nov 2000 20:55:36 -0500
This is a multi-part message in MIME format.



------=_NextPart_000_012F_01C054C6.903034B0

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Assuming IDNumber is numeric, the code should read:



    strSQL =3D "SELECT * FROM EmployeeTable WHERE IDNumber =3D " & 

Session("IDNumber")



  ----- Original Message -----

  From: Leo Clayton

  To: ASP Databases

  Sent: Wednesday, November 22, 2000 3:10 PM

  Subject: [asp_databases] Select Statement





  Can someone tell me what is wrong with this Select statement that 

causes the following error:



  Microsoft VBScript compilation error '800a0401'



  Expected end of statement



  /EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line 25



  strSQL =3D "SELECT * FROM EmployeeTable WHERE IDNumber =3D 

Session('"IDNumber"');"

  

-------------------------------------------------------------------------

--------------------------------------^



  I want to SELECT the record that has an IDNumber that matches the 

Session("IDNumber") and if it does I want to write the output in a table 

format.  Here is my code:



  <% @LANGUAGE =3D "VBSCRIPT" %>



  <% Response.Buffer =3D True %>



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

  <HTML>

  <HEAD>



  <TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

  </HEAD>



  <BODY BGCOLOR=3D"FFFF80">

  <CENTER>

  <H1>EMPLOYEE MASTER DATABASE<BR>

  UPDATING THE EMPLOYEE TABLE</H1>

  </CENTER>



  <%

  Response.Write ("The File Selected To Be Updated is ")

  Response.Write (Request.Form("TableToBeUpdated"))

  %>



  <%



  If Request.Form("TableToBeUpdated") =3D "Employee" Then

          strSQL =3D "SELECT * FROM EmployeeTable WHERE IDNumber =3D 

Session('"IDNumber"');"

          Set DbObj =3D Server.CreateObject("ADODB.CONNECTION")

          DbObj.Open "DSN=3DEmployeeMaster"

          Set oRs =3D DbObj.Execute(strSQL)

  <TABLE BORDER=3D3>

  <TR>

  <TD>    <% =3DoRs.Fields("FirstName").Value %>    </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("LastName").Value %>    </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("Title").Value %>       </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("Education").Value %>   </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("JobHistory").Value %>  </TD>

  </TR>

  </Table>



  '       Response.Redirect "SelectFieldsToUpdate.asp"

  'Else

  'Response.Redirect "UpdateEmployeeSkillsTable.asp"

  'End If

  End If

  %>



  </BODY>

  </HTML>















  ---

  FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND

  INSIGHTS IN YOUR INBOX!

  Get the latest and best C++, Visual C++, Java, Visual Basic, and XML 

tips, tools, and

  developments from the experts. Sign up for one or more of EarthWeb?s

  FREE IT newsletters at http://www.earthweb.com today!




$subst('Email.Unsub')








Message #4 by "jigs gandhi" <newsgroup@h...> on Thu, 23 Nov 2000 09:18:41 +0530
This is a multi-part message in MIME format.



------=_NextPart_000_01A1_01C0552E.5EC99660

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable





hi,



correct your query to be



strSQL =3D "SELECT * FROM EmployeeTable WHERE IDNumber =3D" &  

Session('"IDNumber"')



jigs

  ----- Original Message -----

  From: Leo Clayton

  To: ASP Databases

  Sent: Thursday, November 23, 2000 1:40 AM

  Subject: [asp_databases] Select Statement





  Can someone tell me what is wrong with this Select statement that 

causes the following error:



  Microsoft VBScript compilation error '800a0401'



  Expected end of statement



  /EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line 25



  strSQL =3D "SELECT * FROM EmployeeTable WHERE IDNumber =3D 

Session('"IDNumber"');"

  

-------------------------------------------------------------------------

--------------------------------------^



  I want to SELECT the record that has an IDNumber that matches the 

Session("IDNumber") and if it does I want to write the output in a table 

format.  Here is my code:



  <% @LANGUAGE =3D "VBSCRIPT" %>



  <% Response.Buffer =3D True %>



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

  <HTML>

  <HEAD>



  <TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

  </HEAD>



  <BODY BGCOLOR=3D"FFFF80">

  <CENTER>

  <H1>EMPLOYEE MASTER DATABASE<BR>

  UPDATING THE EMPLOYEE TABLE</H1>

  </CENTER>



  <%

  Response.Write ("The File Selected To Be Updated is ")

  Response.Write (Request.Form("TableToBeUpdated"))

  %>



  <%

  If Request.Form("TableToBeUpdated") =3D "Employee" Then

          strSQL =3D "SELECT * FROM EmployeeTable WHERE IDNumber =3D 

Session('"IDNumber"');"

          Set DbObj =3D Server.CreateObject("ADODB.CONNECTION")

          DbObj.Open "DSN=3DEmployeeMaster"

          Set oRs =3D DbObj.Execute(strSQL)

  <TABLE BORDER=3D3>

  <TR>

  <TD>    <% =3DoRs.Fields("FirstName").Value %>    </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("LastName").Value %>    </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("Title").Value %>       </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("Education").Value %>   </TD>

  </TR>

  <TR>

  <TD>    <% =3DoRs.Fields ("JobHistory").Value %>  </TD>

  </TR>

  </Table>



  '       Response.Redirect "SelectFieldsToUpdate.asp"

  'Else

  'Response.Redirect "UpdateEmployeeSkillsTable.asp"

  'End If

  End If

  %>



  </BODY>

  </HTML>















  ---

  FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND

  INSIGHTS IN YOUR INBOX!

  Get the latest and best C++, Visual C++, Java, Visual Basic, and XML 

tips, tools, and

  developments from the experts. Sign up for one or more of EarthWeb?s

  FREE IT newsletters at http://www.earthweb.com today!




$subst('Email.Unsub')








Message #5 by Navani <navanid@y...> on Wed, 22 Nov 2000 20:43:46 -0800 (PST)
Hi Leo Clayton,



 The following statement will solve the problem



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber="

& Session("IDNumber")





Cheers,

Navani





--- Leo Clayton <claytonl@z...> wrote:

> Can someone tell me what is wrong with this Select

> statement that causes 

> the following error:

> 

> Microsoft VBScript compilation error '800a0401'

> 

> Expected end of statement

> 

> /EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line

> 25

> 

> strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber

> = Session('"IDNumber"');"

>

----------------------------------------------------------------------------

> 

> -----------------------------------^

> 

> I want to SELECT the record that has an IDNumber

> that matches the 

> Session("IDNumber") and if it does I want to write

> the output in a table 

> format.  Here is my code:

> 

> <% @LANGUAGE = "VBSCRIPT" %>

> 

> <% Response.Buffer = True %>

> 

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2

> Final//EN">

> <HTML>

> <HEAD>

> 

> <TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

> </HEAD>

> 

> <BODY BGCOLOR="FFFF80">

> <CENTER>

> <H1>EMPLOYEE MASTER DATABASE<BR>

> UPDATING THE EMPLOYEE TABLE</H1>

> </CENTER>

> 

> <%

> Response.Write ("The File Selected To Be Updated is

> ")

> Response.Write (Request.Form("TableToBeUpdated"))

> %>

> 

> <%

> If Request.Form("TableToBeUpdated") = "Employee"

> Then

>          strSQL = "SELECT * FROM EmployeeTable WHERE

> IDNumber = 

> Session('"IDNumber"');"

>          Set DbObj 

> Server.CreateObject("ADODB.CONNECTION")

>          DbObj.Open "DSN=EmployeeMaster"

>          Set oRs = DbObj.Execute(strSQL)

> <TABLE BORDER=3>

> <TR>

> <TD>    <% =oRs.Fields("FirstName").Value %>   

> </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("LastName").Value %>   

> </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("Title").Value %>      

> </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("Education").Value %>  

> </TD>

> </TR>

> <TR>

> <TD>    <% =oRs.Fields ("JobHistory").Value %> 

> </TD>

> </TR>

> </Table>

> 

> '       Response.Redirect "SelectFieldsToUpdate.asp"

> 'Else

> 'Response.Redirect "UpdateEmployeeSkillsTable.asp"

> 'End If

> End If

> %>

> 

)<BR>

> 

> </BODY>

> </HTML>

> 

Message #6 by Imar Spaanjaars <Imar@S...> on Thu, 23 Nov 2000 07:46:03 +0100
You aren't adding the value of the Session("IDNumber"), but the string 

Session("IDNumber")



Try this instead:



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = " & Session('"IDNumber")





HtH



Imar



At 03:10 PM 11/22/2000 -0500, you wrote:

>Can someone tell me what is wrong with this Select statement that causes 

>the following error:

>

>Microsoft VBScript compilation error '800a0401'

>

>Expected end of statement

>

>/EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line 25

>

>strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = Session('"IDNumber"');"

>---------------------------------------------------------------------------------------------------------------^

>

>I want to SELECT the record that has an IDNumber that matches the 

>Session("IDNumber") and if it does I want to write the output in a table 

>format.  Here is my code:

>

><% @LANGUAGE = "VBSCRIPT" %>

>

><% Response.Buffer = True %>

>

><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

><HTML>

><HEAD>

>

><TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

></HEAD>

>

><BODY BGCOLOR="FFFF80">

><CENTER>

><H1>EMPLOYEE MASTER DATABASE<BR>

>UPDATING THE EMPLOYEE TABLE</H1>

></CENTER>

>

><%

>Response.Write ("The File Selected To Be Updated is ")

>Response.Write (Request.Form("TableToBeUpdated"))

>%>

>

><%

>If Request.Form("TableToBeUpdated") = "Employee" Then

>         strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = 

> Session('"IDNumber"');"

>         Set DbObj = Server.CreateObject("ADODB.CONNECTION")

>         DbObj.Open "DSN=EmployeeMaster"

>         Set oRs = DbObj.Execute(strSQL)

><TABLE BORDER=3>

><TR>

><TD>    <% =oRs.Fields("FirstName").Value %>    </TD>

></TR>

><TR>

><TD>    <% =oRs.Fields ("LastName").Value %>    </TD>

></TR>

><TR>

><TD>    <% =oRs.Fields ("Title").Value %>       </TD>

></TR>

><TR>

><TD>    <% =oRs.Fields ("Education").Value %>   </TD>

></TR>

><TR>

><TD>    <% =oRs.Fields ("JobHistory").Value %>  </TD>

></TR>

></Table>

>

>'       Response.Redirect "SelectFieldsToUpdate.asp"

>'Else

>'Response.Redirect "UpdateEmployeeSkillsTable.asp"

>'End If

>End If

>%>

>

></BODY>

></HTML>

>

>

>

>

>

>

>

Message #7 by Stephane_Dattenny@D... on Thu, 23 Nov 2000 02:33:38 -0600
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C05527.98C845A2

Content-Type: text/plain;

	charset="iso-8859-1"



The string must be:

 

strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = " &

Session("IDNumber")" & ";"



(Assuming that IDNumber is not a char or varchar type).



Stephane Dattenny<?xml:namespace prefix = o ns 

"urn:schemas-microsoft-com:office:office" />



Dell Computers - EMEA IT - VB and Web developer



Phone: +33 (0)4 99 75 49 88 



  <file://C:\WINNT\Profiles\stephane_dattenny\Application

Data\Microsoft\Signatures\./Steph_files/image002.gif> 



 



-----Original Message-----

From: Leo Clayton [mailto:claytonl@z...]

Sent: Wednesday, November 22, 2000 9:10 PM

To: ASP Databases

Subject: [asp_databases] Select Statement





Can someone tell me what is wrong with this Select statement that causes the

following error:



Microsoft VBScript compilation error '800a0401' 



Expected end of statement 



/EmployeeMasterStuff/UpdateEmployeeMaster2.asp, line 25 



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber 

Session('"IDNumber"');"

----------------------------------------------------------------------------

-----------------------------------^



I want to SELECT the record that has an IDNumber that matches the

Session("IDNumber") and if it does I want to write the output in a table

format.  Here is my code:



<% @LANGUAGE = "VBSCRIPT" %>



<% Response.Buffer = True %>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>

<HEAD>



<TITLE>UPDATING THE EMPLOYEE TABLE</TITLE>

</HEAD>



<BODY BGCOLOR="FFFF80">

<CENTER>

<H1>EMPLOYEE MASTER DATABASE<BR>

UPDATING THE EMPLOYEE TABLE</H1>

</CENTER>



<%

Response.Write ("The File Selected To Be Updated is ")

Response.Write (Request.Form("TableToBeUpdated"))

%>



<% 

If Request.Form("TableToBeUpdated") = "Employee" Then

        strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber 

Session('"IDNumber"');"

        Set DbObj = Server.CreateObject("ADODB.CONNECTION")

        DbObj.Open "DSN=EmployeeMaster"

        Set oRs = DbObj.Execute(strSQL)

<TABLE BORDER=3>

<TR>

<TD>    <% =oRs.Fields("FirstName").Value %>    </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("LastName").Value %>    </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("Title").Value %>       </TD>



</TR>

<TR>

<TD>    <% =oRs.Fields ("Education").Value %>   </TD>

</TR>

<TR>

<TD>    <% =oRs.Fields ("JobHistory").Value %>  </TD>

</TR>

</Table>



'       Response.Redirect "SelectFieldsToUpdate.asp"

'Else

'Response.Redirect "UpdateEmployeeSkillsTable.asp"

'End If

End If

%>



</BODY>

</HTML>















--- 

FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND

INSIGHTS IN YOUR INBOX!

Get the latest and best C++, Visual C++, Java, Visual Basic, and XML tips,

tools, and 

developments from the experts. Sign up for one or more of EarthWeb?s

FREE IT newsletters at http://www.earthweb.com today! 











Message #8 by dany.kattar@f... on Thu, 23 Nov 2000 07:22:37 -0000
Leo,



try to replace in your code the following instruction:



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber 

Session('"IDNumber"');"



By this one if IDNumber is a number :



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = " &

Session("IDNumber") & " ;"



or this if IDNuimber is a string :



strSQL = "SELECT * FROM EmployeeTable WHERE IDNumber = '" &

Session("IDNumber") & "' ;"





Hope this will help,

Cheers

Danny


  Return to Index