Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to update another field in the same sql comman

Author  Topic 

hanarina
Starting Member

4 Posts

Posted - 2007-04-04 : 23:30:41
i have problem when i want to update another field in the same sql command
i have tried this code:
"SQL = "UPDATE items SET item_status= 'issued' WHERE NO_INVENTORI= '" & Text5.Text & "' "
Set RS = Nothing
Set RS = con.Execute(SQL)
con.Close
"
an error occured said that" [Microsoft ](ODBC Microsoft Access Driver too few parameters.Expected 1."
what that does mean?
help me pliz..

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-04 : 23:56:40
Instead of

Set RS = con.Execute(SQL)

use

con.Execute(SQL)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hanarina
Starting Member

4 Posts

Posted - 2007-04-05 : 00:18:53
quote:
Originally posted by madhivanan

Instead of

Set RS = con.Execute(SQL)

use

con.Execute(SQL)


Madhivanan

thanks for the suggestions, i've tried but still the same error occured..why?i dont know how to fix it..

Failing to plan is Planning to fail

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-05 : 01:18:48
Make sure that you have used correct column names

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hanarina
Starting Member

4 Posts

Posted - 2007-04-05 : 02:40:02
i've tried so many times,my column names is correct,what is the problem?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-05 : 02:55:35
Post full code.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

hanarina
Starting Member

4 Posts

Posted - 2007-04-05 : 03:24:43
sql1 = "select * from BORROW"
Set con = CreateObject("Adodb.connection")
con.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "/BORROWSYSTEM.mdb"
Set RS = CreateObject("ADODB.Recordset")

RS.Open sql1, con, adOpenDynamic, adLockOptimistic
RS.AddNew
RS("NO_INVENTORI") = Text5.Text
RS("ID_NO") = Text1.Text
RS("NAME") = Text2.Text
RS("SECTOR") = Text3.Text
RS("ITEMS_NAME") = Text4.Text
RS("DATE_BORROWED") = DTPicker1.Value
RS("DATE_RETURN") = DTPicker2.Value
RS("ITEMS_STATUS") = "issued"
RS("DATE") = Date
RS.Update


SQL = "UPDATE items SET ITEMS_STATUS = 'issued' WHERE NO_INVENTORI= '" & Text5.Text & "' "
Set RS = Nothing
con.Execute (SQL)
con.Close
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-05 : 03:57:10
SQL = "UPDATE items SET ITEMS_STATUS = 'issued' WHERE NO_INVENTORI= '" & Text5.Text & "' "
Set RS = Nothing -- THIS LINES DESTROYS THE RECORDSET!!!!!
con.Execute (SQL)
con.Close


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-04-05 : 08:06:29
Also i see there is a scope for SQL Injection.

Make sure that Text5.Text doesnt contain any single Quote (')

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page
   

- Advertisement -