Re: Incorrect syntax near '='

Tech-Archive recommends: Fix windows errors by optimizing your registry



For one thing, you don't have a space between the table name and WHERE. How
about printing out the value of strSQL?

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"Denis" <Denis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:15DAF6BC-4809-479E-9B80-10B33955D4C1@xxxxxxxxxxxxxxxx
Greetings,

I have attempted to code the following into a sql server 2000 acccess
database.

strSQL = "SELECT * FROM tblDocumentTypes" & _
"WHERE DocType =" & "'" & DcmntTyp & "'" & ";"
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = strSQL
cmd.CommandType = adCmdText
cmd.Execute

I have also tried

strSQL = "SELECT * FROM tblDocumentTypes" & _
"WHERE DocType = ? ;"
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = strSQL
cmd.CommandType = adCmdText
cmd.Parameters.Append cmd.CreateParameter("iDcmntTypNm", adVarChar,
adParamInput, 50, DcmntTyp)
cmd.Execute

DcmntTyp contains a user entered value from a text box.

I have tried a number of other ways of writing this code but I keep getting
the error "Incorrect syntax near '='".

Any help to resolve this will be greatly appreciated.
--
Denis

.



Relevant Pages

  • Re: Newbe question
    ... >Thomas A. Moreau, BSc, PhD, MCSE, MCDBA ... >Columnist, SQL Server Professional ... >The second column contains data that I want to move to ...
    (microsoft.public.sqlserver.security)
  • Re: How to prevent a lock escalation to a table level ?
    ... > Columnist, SQL Server Professional ... >> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA ...
    (microsoft.public.sqlserver.server)
  • Re: Persisting ADO as XML - almost convinced im crazy!
    ... "Tom Moreau" wrote in message ... > Columnist, SQL Server Professional ... >> SQL Server MVP ...
    (microsoft.public.vb.database.ado)
  • Re: DB ist auf SQL2005 langsamer
    ... Thomas Finkbeiner schrieb ... ... Deine Interpretation meiner Antwort ist mir so gar nicht in den Sinn ... obwohl Du bereits in Hardware ... Applikation wie der SQL Server von dem flachen Speichermodell ...
    (microsoft.public.de.sqlserver)
  • Re: Convert help needed desperately
    ... Columnist, SQL Server Professional ... "Tom Moreau" wrote in message ... > Cannot insert a non-null value into a timestamp column. ...
    (microsoft.public.sqlserver.programming)