Problems deleting records from an Access DB

Results 1 to 3 of 3

Thread: Problems deleting records from an Access DB

  1. #1
    Robert Wright Guest

    Default Problems deleting records from an Access DB

    This may be an easy answer, but I have been unsuccessful in deleting any records from my Access DB. Thanks for your help.<BR><BR>I constantly get the following error:<BR> <BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e10&#039 <BR>[Microsoft][ODBC Microsoft Access 97 Driver] Too few parameters. Expected 1. <BR> <BR>Here is the code:<BR><BR>&#060;% <BR>&#039 this code opens the database<BR>Dim objConn<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .ConnectionString = "DSN=Rob"<BR>objConn.Open<BR><BR>&#039 this code allows me to talk to the database<BR>Dim objRS<BR>Set objRS = Server.CreateObject("ADODB.Recordset") <BR><BR>Dim storevariable<BR>storevariable=request.querystring ("storename")<BR><BR>Dim strSQL<BR>strSQL = "DELETE FROM STORE WHERE Stores="<BR>strSQL = strSQL + request.querystring("storename")<BR>objRS.Open strSQL,objConn <BR><BR>&#039Close the Recordset object<BR>objRS.Close<BR><BR>&#039Delete the Recordset Object<BR>Set objRS = Nothing<BR><BR>&#039Close the Connection object<BR>objConn.Close<BR><BR>&#039Delete the Connection Object<BR>Set objConn = Nothing <BR>%&#062;

  2. #2
    Join Date
    Dec 1969
    Posts
    1,019

    Default RE: Problems deleting records from an Access DB

    The error indicates the sql statement is incorrect; either a table/field or the querystring variable is incorrect. Try writing out the statement as in the example below. Also, you should use & not + for string concatenation and for access deletions you must use a * to indicate all fields:<BR>&#060;%<BR>Dim strSQL<BR>strSQL = "DELETE * FROM STORE WHERE Stores="<BR>&#039 add in the *<BR><BR>strSQL = strSQL & request.querystring("storename")<BR>&#039 use an ampersand<BR><BR>response.write strSQL<BR>&#039this will show you the query you are passing to the db<BR><BR>objRS.Open strSQL,objConn <BR>%&#062;<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    41

    Default RE: Problems deleting records from an Access DB

    If the Stores field is a text field then you must put &#039single quotes&#039 around the value. Like:<BR>strSQL = "DELETE FROM STORE WHERE Stores=&#039"<BR>strSQL = strSQL + request.querystring("storename") + "&#039"<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •