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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

S.O.S: "objRS.Delete" Problems!!

Status
Not open for further replies.

adamsoderqvist

Programmer
Sep 8, 2001
136
SE
I'm tryin to delete a record in access using onjRS.Delete. It's worked before, but now - all of a sudden - I get an error msg:

"[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11."

Help, pls...!
 
OK, here goes:

'Declare connection...
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)}; " & "DBQ=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "WebForum\User_Accounts.mdb"
objConn.Open

'Declare recordset object...
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")

'Declare SQL query.
Dim strSQL
strSQL = "SELECT * FROM tblUsers WHERE UserID=" & Request.QueryString("UserID")

'Open the database and get the requested info!
objRS.Open strSQL, objConn, , adLockOptimistic

objRS.MoveFirst
objRS.Delete

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

---

As I said: it works with another application that works the same way, but now it just doesn't!

And yes, - all files are in the directories were they should be, etc...

thanx!
 
i've never heard of and couldn't find a recordset.delete command, but there is deleterecord:


or why don't you use the sql statement delete, replacing:

'Declare recordset object...
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")

'Declare SQL query.
Dim strSQL
strSQL = "SELECT * FROM tblUsers WHERE UserID=" & Request.QueryString("UserID")

'Open the database and get the requested info!
objRS.Open strSQL, objConn, , adLockOptimistic

objRS.MoveFirst
objRS.Delete

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

with:

'Declare SQL query.
Dim strSQL
strSQL = "DELETE FROM tblUsers WHERE UserID=" & Request.QueryString("UserID")

objConn.Execute strSQL

objConn.Close
Set objConn = Nothing
 
Thanx - That really helped!! (though there REALLY is an objRS.Delete - command!! Really... I've used it!)

Anyway.

I have another one for you:
I want the user to be able to pick from what time period he/she want to view posts. I.e.: let's say I have a list box with;
"View Posts from:
(drop-down list box)
Yesterday
This week
All

Since I do MS Access and not pure SQL, it returns a "Type missmatch" when I use an SQL statement such as:

strSQL = &quot;Select * From tblNews Where PostDate > vbToday AND < vbToday - 7&quot;

My guess is that since the PostDate coulmn is defined as &quot;Date&quot; in MS Access, and strSQL is a string, the type missmatch is a fact!! - What to do??

//A
 
i've never used it, but i found this function:

DateValue(mystring)

maybe this will work:

strSQL = &quot;Select * From tblNews Where PostDate > #&quot; & DateValue(vbToday) & &quot;# AND < #&quot; & DateValue(vbToday) - 7 & &quot;#&quot;



 
No, it didn't work out...!

It still returns a Type missmatch, - so it's probably due to a conflict between the string and the date field, because when I define the PostDate-field as Text, it works!

Any idea on how to solve it in another way..?

thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top