|
 |
asp_databases thread: SQL SELECT statements...
Message #1 by "Matthew Sherman" <mrpeanut1@j...> on Fri, 27 Apr 2001 16:09:25
|
|
I'm having a problem using SQL SELECT statements. Here is a sample of the
code I am using:
<%
If strSearch <> "" Then
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=MTR"
strSQL = "SELECT FIELD2 FROM MTR WHERE FIELD2 LIKE strFIELD2;"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.PageSize = PAGE_SIZE
objRS.CacheSize = PAGE_SIZE
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly,
adCmdTable
iRecordCount = objRS.RecordCount
iPageCount = objRS.PageCount
If iRecordCount = 0 Then
%>
Here is the error I am receiving:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC dBase Driver] Syntax error in FROM clause
I'm not quite sure what I'm doing wrong. Please help me.
Thanks
Message #2 by Gregory_Griffiths@c... on Fri, 27 Apr 2001 16:29:25 +0100
|
|
try :
strSQL = "SELECT FIELD2 FROM MTR WHERE FIELD2 LIKE 'strFIELD2';"
Don't forget that you may want to use Wildcards as well.
> -----Original Message-----
> From: mrpeanut1@j... [mailto:mrpeanut1@j...]
> Sent: 27 April 2001 16:29
> To: asp_databases@p...
> Cc: mrpeanut1@j...
> Subject: [asp_databases] SQL SELECT statements...
>
>
> I'm having a problem using SQL SELECT statements. Here is a
> sample of the
> code I am using:
>
> <%
> If strSearch <> "" Then
>
> Set objConn = Server.CreateObject("ADODB.Connection")
>
> objConn.Open "DSN=MTR"
>
> strSQL = "SELECT FIELD2 FROM MTR WHERE FIELD2 LIKE strFIELD2;"
>
> Set objRS = Server.CreateObject("ADODB.Recordset")
>
> objRS.PageSize = PAGE_SIZE
> objRS.CacheSize = PAGE_SIZE
>
> objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly,
> adCmdTable
>
> iRecordCount = objRS.RecordCount
> iPageCount = objRS.PageCount
>
> If iRecordCount = 0 Then
> %>
>
> Here is the error I am receiving:
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [Microsoft][ODBC dBase Driver] Syntax error in FROM clause
>
> I'm not quite sure what I'm doing wrong. Please help me.
>
> Thanks
>
>
>
Message #3 by "Tomm Matthis" <matthis@b...> on Fri, 27 Apr 2001 13:14:33 -0400
|
|
Try this:
strSQL =3D "SELECT FIELD2 FROM MTR WHERE FIELD2 LIKE " & strFIELD & ";"
Tomm
> -----Original Message-----
> From: Matthew Sherman [mailto:mrpeanut1@j...]
> Sent: Friday, April 27, 2001 11:29 AM
> To: ASP Databases
> Subject: [asp_databases] SQL SELECT statements...
>
>
> I'm having a problem using SQL SELECT statements. Here is a
> sample of the
> code I am using:
>
> <%
> If strSearch <> "" Then
>
> Set objConn =3D Server.CreateObject("ADODB.Connection")
>
> objConn.Open "DSN=3DMTR"
>
> strSQL =3D "SELECT FIELD2 FROM MTR WHERE FIELD2 LIKE strFIELD2;"
>
> Set objRS =3D Server.CreateObject("ADODB.Recordset")
>
> objRS.PageSize =3D PAGE_SIZE
> objRS.CacheSize =3D PAGE_SIZE
>
> objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly,
> adCmdTable
> =09
> iRecordCount =3D objRS.RecordCount
> iPageCount =3D objRS.PageCount
>
> If iRecordCount =3D 0 Then
> %>
>
> Here is the error I am receiving:
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [Microsoft][ODBC dBase Driver] Syntax error in FROM clause
>
> I'm not quite sure what I'm doing wrong. Please help me.
>
> Thanks
>
>
>
> ---
> SoftArtisans helps developers build robust, scalable Web applications!
> Excel Web reports, charts:
http://www.softartisans.com/excelwriter.html
> File uploads: http://www.softartisans.com/saf.html
> Transactional file management: http://www.softartisans.com/saf1.html
> Scalability: http://www.softartisans.com/saxsession.html
> ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
> $subst('Email.Unsub')
>
>
Message #4 by "Jason Byrnes" <byrnes@f...> on Mon, 30 Apr 2001 09:43:25 -0400
|
|
I had a simalar problem not to long ago, and it turned out to be that I was
using "adCmdTable" as the command type when using an SQL statement.
try canging:
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdTable
to:
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText
"adCmdTable" means that youre passing the table name and nothing else, where
"adCmdText" tells ADO that youre using an SQL statement.
I pulled my hair out on this one for a few days myself, hope this helps.
Jason
"Matthew Sherman" <mrpeanut1@j...> wrote in message
news:60680@a..._databases...
>
> I'm having a problem using SQL SELECT statements. Here is a sample of the
> code I am using:
>
> <%
> If strSearch <> "" Then
>
> Set objConn = Server.CreateObject("ADODB.Connection")
>
> objConn.Open "DSN=MTR"
>
> strSQL = "SELECT FIELD2 FROM MTR WHERE FIELD2 LIKE strFIELD2;"
>
> Set objRS = Server.CreateObject("ADODB.Recordset")
>
> objRS.PageSize = PAGE_SIZE
> objRS.CacheSize = PAGE_SIZE
>
> objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly,
> adCmdTable
>
> iRecordCount = objRS.RecordCount
> iPageCount = objRS.PageCount
>
> If iRecordCount = 0 Then
> %>
>
> Here is the error I am receiving:
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [Microsoft][ODBC dBase Driver] Syntax error in FROM clause
>
> I'm not quite sure what I'm doing wrong. Please help me.
>
> Thanks
>
>
>
>
|
|
 |