.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Visual Basic - Synchronize Client Computer Date/Time From a SQL Server

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

The code below is used to synchronize the client computer from MS SQL Server, sometimes the users  may change their computer local time in-order to trick the system that he/she encoded the data entry on time. Oh, if you're the database administrator or programmer it's a very headache how to figure it out, why it is happen this way. Sample scenario, accounts receivable should be encoded prior to cut-off period, then user name "Michelle" forgot to encode the data, a day after cut-off period she realize encode the accounts receivable data, she might change the local time in-order to encode in previous dates. Basically, visual basic program compares the entry date (date picker component) and the system/local time, if she change the system date less than current date, you might wonder why the data not posted in ledger to think that all entries are encoded on timely basis. So, how to prevent it. Use the code below and don't forget to create a stored procedure called "Get_Server_Date". Call this function as many as you can for example during Loan Event, Add New Entry, Edit Entry, Save Entry, Delete Entry. Anyway it's very fast, the user can't recognize that you're synchronizing from the server time.
Note: I assume the all your data tables has these two or three fields
User_Name - the one who transact the data
DateEncoded/Modified  - the transaction date base on user's local time.
Computer Name - Optional, it use to trace the users location.
If it's not added to your data table, please do apply the fields it may help you trace your transactions.

'------ VB Code ----------
'Declaration
Dim Const mCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Mydatabase;Data Source=MyComputerName\SQLEXPRESS"



'Note : Change the Mydatabase to your Database Name
 '            MyComputerNmae = Your Database Server Name





Private Sub Form_Load()




       Call SynChronize_Date_Server()

End Sub



Function SynChronize_Date_Server()
On Error Resume Next
    Dim tmp1 As Date
    With Main.ado1   ' Add adodc1 object to the form and name it ado1
        .ConnectionString = mCon
        .CommandType = adCmdStoredProc
        .RecordSource = "sp_getserverdate;1"
        .Refresh
        Date = Format(.Recordset!ServerDate, "mm/dd/yy")
        Time = Format(.Recordset!ServerDate, "hh:mm:ss")
    End With
End Function

Function Get_Server_Date() As Date

On Error Resume Next
    Dim tmp1 As Date
    With Main.ado1
        .ConnectionString = mCon
        .CommandType = adCmdStoredProc
        .RecordSource = "sp_getserverdate;1"
        .Refresh
        Get_Server_Date = Format(.Recordset!ServerDate, "mm/dd/yy")
    End With
End Function
'-------------------------------- STORED PROCEDURED CODE ----------------------------


USE [Inventry]
GO
/****** Object:  StoredProcedure [dbo].[sp_getserverdate]    

Script Date: 04/20/2010 01:19:56 ******/

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER  proc [dbo].[sp_getserverdate]
as
set nocount on
select getdate() as ServerDate





















Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Visual Basic - Synchronize Client Computer Date/Time From a SQL Server, Diterbitkan oleh scodeaplikasi pada Rabu, 07 April 2010. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to