boogieoompa Posted September 20, 2012 Share Posted September 20, 2012 (edited) I'm not sure why but I cannot get my DB to update. I am able to query it fine indicating that the DB is in fact setup but my updates are currently not doing anything. I'm sure its some easy thing I'm overlooking. Any thoughts/suggestions? Func FunUpdate() Local $title,$adoCon,$dbname,$adoRs, $_output $adoCon = ObjCreate("ADODB.Connection") $dbname = @ScriptDir & "" & "Database.mdb" $adoCon.Open ("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $dbname) $adoRs = ObjCreate ("ADODB.Recordset") $adoRs.CursorType = 1 $adoRs.LockType = 3 $adoRs.open("Update Main SET LastName = 'blah' WHERE ID = 2", $adoCon) $adoCon.Close EndFunc Edited September 20, 2012 by boogieoompa Link to comment Share on other sites More sharing options...
StringingLong Posted September 21, 2012 Share Posted September 21, 2012 I see you don't you have error code in place to test (tsk tsk) When you write code from the start, always check for errors to bleed out the problems. Then, if you are 100% sure the code is working, remove error checking *IF* desired. Use @error throughout your code and throw up a MsgBox $adoCon = ObjCreate("ADODB.Connection") if @error then MsgBox(0,"Database Error", "Could not create database object") Exit endif $adoCon.Open("whatever") if @error then MsgBox(0,"Database Error", "Could not connect to SQL Server") Exit endif $adoRs = ObjCreate("ADODB.RecordSet") if @error then MsgBox(0,"Database Error", "Could not create database recordset") Exit endif . . $adoRs.open("blah blah blah") if @error then MsgBox(0,"Database Error", "Could not execute SQL statement") Exit endif Also, is it $adoRs.open or should it be $adoRs.Execute() instead? Or should it really be using the connection object to make the SQL call? (i.e. $adoCon.Open() or $adoCon.Execute()) Hmmmm! Other things to check just in case: Is Main a valid table name? Is LastName (upper case and lower case) a valid column? Is ID (upper case and lower case) a valid column? How about ID of 2? Does the record even exist in the table? Food for thought. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now