Strings in INSERT SQL string

Results 1 to 2 of 2

Thread: Strings in INSERT SQL string

  1. #1
    Warren G Guest

    Default Strings in INSERT SQL string

    Hi,<BR><BR> Can anyone tell me how to insert strings into access using the SQL &#039INSERT&#039 command.<BR><BR>As strings require that they are surrounded by double quotes it confuses the string. I get the following error<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e10&#039 <BR><BR>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. <BR><BR>/waz/utilities.asp, line 32 <BR><BR>the code in question is:<BR><BR>strSQL ="INSERT INTO SubscriberInfo (ContactID, emailAddress) VALUES ("&requestedNum&","&chr(34)&email&chr(34)&")"<BR>< BR> Response.Write strSQL<BR> Response.Write "<BR>"<BR><BR> writeToDB(strSQL)<BR><BR>and the writeToDB(strSQL) sub looks like this:<BR><BR>sub writeToDB(sqlString)<BR> Dim objRS<BR> Set objRS = Server.CreateObject("ADODB.Recordset") <BR> objConn.Execute(sqlString)<BR>end sub<BR><BR>Also can anyone tell me how to check if a recordset doesn&#039t contain any fields (ie the select command didn&#039t find any matches).<BR><BR>Cheers,<BR><BR>Warren

  2. #2
    Larry Villella Guest

    Default RE: Strings in INSERT SQL string

    For your first question, there are two possibilities. Whenever you want to include an ACTUAL double-quote, you can use a quote escape character. So, if I want to set a string:<BR><BR>str=" ""Happy "" "<BR><BR>The actual string is "Happy". This will pass the double quote along in your SQL Statement.<BR><BR>However, I&#039m pretty sure strings, even in access, don&#039t require a double-quote. You should be able to surround them with a single quote.<BR><BR>For your second question:<BR><BR>if objRS.eof then<BR> &#039recordset is empty, no records returned<BR>else<BR> &#039Something was returned<BR>end if<BR><BR>Hope this helps<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