Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

if(computer.speed == "slow")
    {  
       hamster.feed();  
    }
if(computer.speed == "really slow")
    {  
        hamster.kill();
        BuyNewHamster();
    }

Posted

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 ?

Posted
It's when I run the program. Apparently when it comes to my SQL statement it finds the error.
if(computer.speed == "slow")
    {  
       hamster.feed();  
    }
if(computer.speed == "really slow")
    {  
        hamster.kill();
        BuyNewHamster();
    }

Posted

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

Posted

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

Code today gone tomorrow!
Posted
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
if(computer.speed == "slow")
    {  
       hamster.feed();  
    }
if(computer.speed == "really slow")
    {  
        hamster.kill();
        BuyNewHamster();
    }

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...