Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT STATMENT ERROR 1

Status
Not open for further replies.

ukwebsite

Programmer
Dec 9, 2000
82
GB
Hello. Im trying to insert data into an Access database. How can I replace "Ladies_Dresses" with a variable. I wish to use
strArea = Request.QueryString("Area") and put the variable strArea instead of the "Ladies_Dresses


Code

objRS.Open &quot;Select * FROM Ladies_Dresses WHERE 1<>1&quot;,objConn

objRS.AddNew
objRS( &quot;DateAdded&quot; ) = strDateAdded
objRS( &quot;Description&quot; ) = strDescription
objRS( &quot;Colour&quot; ) = strColour
objRS( &quot;Quantity&quot; ) = strQuantity
objRS( &quot;Size&quot; ) = strSize
objRS( &quot;Price&quot; ) = strPrice
objRS.Update
objConn.Close
Set objConn = Nothing

Thanks
Matthew Wilde
matthew@ukwebsite.com
 
strArea = Request.QueryString(&quot;Area&quot;)

objRS.Open &quot;Select * FROM &quot; &amp; strArea &amp; &quot; WHERE 1<>1&quot;,objConn

However, if you want to append a record to the table, I would suggest using a Command object, and using the sql &quot;INSERT INTO ....&quot; for the command object.
Simon
 
I am wondering why you specify the WHERE clause here coz 1 = 1 and 1 cannot be not equal to 1

elighten me if i'm wrong here..

gabor
 
gabor -

I think they were just trying to give us the gist of the question. I'm sure their WHERE clause is written correctly, because otherwise &quot;1<>1&quot; evaluates to false, which would always return 0 rows. The reverse applies if he had said WHERE 1=1, he would then get all rows in the table. Both are newbie mistakes.

Chip H.
 
ChipH,

I disagree with you. I think this WHERE clause is there deliberately to return 0 rows, as the recordset is used to insert another record, and no current records are needed. I think it is done this way, as creating a recordset with 0 records is faster than creating a recordset with > 0 records. But as I mentioned in my last post, if this is the case, another approach would be more suitable.
Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top