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()
Function SynChronize_Date_Server()End Sub
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
Thank you for reading this article Visual Basic - Synchronize Client Computer Date/Time From a SQL Server With URL https://x-tutorials.blogspot.com/2010/04/visual-basic-synchronize-client.html. Also a time to read the other articles.
0 comments:
Write your comment for this article Visual Basic - Synchronize Client Computer Date/Time From a SQL Server above!