hi there ... i need some help .. i m doing a windows service ... it involve capturing pic for the user using the computer every 60 sec interval... i have create a timer and allow it to take every 60 sec and save into the folder... beside tt .. i need to insert into the database .. however it only insert once .. which mean to say when the camera first start taking its first picture it will store into the database .. and after 60 sec the camera will still take the picture however is nt storing into the database .. can someone help me and tell me what to do to let the record insert into the database after the first one is store ... thanks alot for the help (:

here is my code for the INSERT PART (:

public void write(bool write_face)
        {
            
            OleDbConnection Con = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0; Data Source=C:\Users\hp\Documents\Visual Studio 2008\Projects\PATS_084623Q\PATS_084623Q\Database\PATS.mdb");



            if (write_face == false)
            {
                OleDbCommand Insert = new OleDbCommand("INSERT INTO UserLogs (WindowsUsername, DateTimeIn, DateTimeOut,Status) VALUES (@WindowsUsername, @DateTimeIn, @DateTimeOut, FALSE)", Con);

                Insert.Parameters.AddWithValue("@WindowsUsername", OleDbType.Char).Value = win_user_name;
                Insert.Parameters.AddWithValue("@DateTimeIn", OleDbType.DBTime).Value = DateTime.Now.ToOADate();
                Insert.Parameters.AddWithValue("@DateTimeOut", OleDbType.DBTime).Value = DateTime.Now.ToOADate();

                try
                {
                    Con.Open();
                    int x = Insert.ExecuteNonQuery();
                    Con.Close();
                    eventLog1.WriteEntry("Insert log succeed!");
                }
                catch (OleDbException ex)
                {
                    eventLog1.WriteEntry(ex.Message);
                }

            }
            else
            {
                OleDbCommand Insert = new OleDbCommand("INSERT INTO UserLogs (WindowsUsername, DateTimeIn, DateTimeOut,Status,CapturedImage) VALUES (@WindowsUsername, @DateTimeIn, @DateTimeOut, TRUE, @CapturedImage)", Con);
                FileStream image_stream = new FileStream(sPath + "\\temp_face.jpg", FileMode.Open, FileAccess.Read);

                Byte[] image_to_write = new byte[image_stream.Length];
                image_stream.Read(image_to_write, 0, image_to_write.Length);
                image_stream.Close();

                Insert.Parameters.AddWithValue("@WindowsUsername", OleDbType.Char).Value = win_user_name;
                Insert.Parameters.AddWithValue("@DateTimeIn", OleDbType.DBTime).Value = DateTime.Now.ToOADate();
                Insert.Parameters.AddWithValue("@DateTimeOut", OleDbType.DBTime).Value = DateTime.Now.ToOADate();


                oleP.Value = image_to_write;
                Insert.Parameters.Add(oleP);


                try
                {
                    Con.Open();
                    int x = Insert.ExecuteNonQuery();
                    Con.Close();
                    eventLog1.WriteEntry("Insert log succeed!");

                    //Con.Close();
                }
                catch (OleDbException ex)
                {
                    eventLog1.WriteEntry(ex.Message);

                }
            }
        }

oleP seems to be out of scope.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.