dakota97 Posted December 8, 2003 Posted December 8, 2003 Hi all, I'm getting an error in the following code when I run it. It's telling me that I'm missing a ; somewhere, and I can't figure out where. Any Ideas? 'Add the employee's clock out time to the database Dim MyConnection2 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= timeclock.mdb") MyConnection2.Open() Dim strdate As String strdate = Date.Now.ToString Dim MyCommand2 As New OleDbCommand("INSERT Into TimeIn (EndTime) VALUES ('" & strdate & "') WHERE EmpID ='" & TextBox1.Text & "' AND EndTime = '""'", MyConnection2) MyCommand2.ExecuteNonQuery() Thanks in advance, Chris Quote if(computer.speed == "slow") { hamster.feed(); } if(computer.speed == "really slow") { hamster.kill(); BuyNewHamster(); }
Grimfort Posted December 8, 2003 Posted December 8, 2003 This is the line I use: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Database\LogFiles.mdb" yours looks right to me, but where is the error happening ? Is it on the opening of the table, or when you run the command ? Quote
dakota97 Posted December 8, 2003 Author Posted December 8, 2003 It's when I run the program. Apparently when it comes to my SQL statement it finds the error. Quote if(computer.speed == "slow") { hamster.feed(); } if(computer.speed == "really slow") { hamster.kill(); BuyNewHamster(); }
Grimfort Posted December 8, 2003 Posted December 8, 2003 I guessed its when you run the program. Its not likely to happen at any other time now is it :) The endtime parameter does not appear to be filled in, is it ment to be empty string, or nothing (just for you to check). Im guessing that your not actually using a date field in the database, but rather a string field (is this what you want ?). One idea I do it print out the completed string into the debug window, and copy and paste it into access or SQL and test to see if the SQL statment is valid: ie: Debug.Print MyCommand2.CommandText Quote
a_jam_sandwich Posted December 8, 2003 Posted December 8, 2003 The problem seems in your SQL you are trying to run a where clause on an INSERT query if your updating then use the UPDATE sql command other wise remove the WHERE statment in the above query Andy Quote Code today gone tomorrow!
dakota97 Posted December 8, 2003 Author Posted December 8, 2003 sorry Grimfort....brain lapse...a_jam you were right...I wasn't thinking about the INSERT...I used the UPDATE and it worked fine...thanks Quote if(computer.speed == "slow") { hamster.feed(); } if(computer.speed == "really slow") { hamster.kill(); BuyNewHamster(); }
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.