CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Solution Required -URGENT (MS-Access)

    Hi,

    Iam developing an Client Server Application using MS-Access. I use DSN for Connectivity from the Client End.

    My requirement is I want to get the Server (Where the Database Resides) Date & Time for the Client Application.

    I tried using this Statement "Select Date()" in a recordset and viewed the result but it show only the Client Systems Date.

    Get me the Correct Solution..


    Thank you .!!!
    your's
    Soundar

  2. #2
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    Hi, may be this?

    rstTime.CursorLocation = adUseServer

  3. #3
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42
    Hi,,

    Thanks for your reply.

    I tried, on changing the Cursor Location, but still not solved.

    Once again Thanks for your effort.

    Please send your response when your get a solution.

    BYe
    Soundar




    Originally posted by vbUserName
    Hi, may be this?

    rstTime.CursorLocation = adUseServer
    your's
    Soundar

  4. #4
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    Can you send the code?

  5. #5
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Exclamation Hi

    Hi,

    Here is the Coding........

    -----------------------------------------------------------------------------------
    Public DB As New ADODB.Connection
    Public lvRecTime As New ADODB.Recordset


    Dim ConnStr As String

    If DB.State = 1 Then
    DB.Close
    End If
    ConnStr = "Provider=MSDASQL.1;Persist Security Info=False; Data Source=DAttendance"

    DB.Mode = adModeReadWrite
    DB.ConnectionString = ConnStr
    DB.CursorLocation = adUseServer
    DB.Open ConnStr

    If lvRecTime.State = 1 Then
    lvRecTime.Close
    End If
    lvRecTime.Open "Select date(),Time()", DB
    Msgbox lvRecTime.Fields(0)

    -----------------------------------------------------------------------------------

    Am I in the Right path ???

    Convey me Plz

    Bye
    Soundar


    Originally posted by vbUserName
    Can you send the code?
    your's
    Soundar

  6. #6
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452
    Unfortunately, with MS Access there is no way to do this. MS Access will always pull the time from the computer you are on. It is not a database server. If you want to be able to do this, you will need to use another type of database (SQL Server, MSDE (SQL Server Limited), Oracle, DB2, PostgreSQL, MySQL). There are true database servers and will report the time back to you.

    Now for a solution you might be able to use is to write a small app to run on the server with a winsock control, and have that app report the time to you.

    Good Luck and Happy Programming.
    Roger

  7. #7
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42
    Thank you Roger,

    That's the Best Solution.

    Bye


    Originally posted by sotoasty
    Unfortunately, with MS Access there is no way to do this. MS Access will always pull the time from the computer you are on. It is not a database server. If you want to be able to do this, you will need to use another type of database (SQL Server, MSDE (SQL Server Limited), Oracle, DB2, PostgreSQL, MySQL). There are true database servers and will report the time back to you.

    Now for a solution you might be able to use is to write a small app to run on the server with a winsock control, and have that app report the time to you.

    Good Luck and Happy Programming.
    Roger
    your's
    Soundar

  8. #8
    Join Date
    Aug 2003
    Location
    London
    Posts
    515
    You could write a very small COM object that would sit on the server. Then, you could reference this from your Access database and write a function from Access that would call the COM DLL.

    You could then create a query that uses the function you have written in Access!!

    Your COM DLL could simply have 1 function in a class...

    Public Function ServerTime As Date

    ServerTime = Now()

    End Function

    Your Access function would be very similar....

    Public Function GetServerTime As Date

    Dim objServerDLL as YourProject.YourDLL

    Set objServerDLL = New YourProject.YourDLL
    GetServerTime = objServerDLL.ServerTime

    Set objServerDLL = Nothing

    End Function

    You can now use this function in a query, and call the query via your ODBC connection...

    Quite long-winded but should work!

  9. #9
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    or, also...

    Lothar "theGreat" Haensler gave an Api solution to this matter:

    http://www.codeguru.com/vb/articles/1915.shtml
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  10. #10
    Join Date
    Aug 2003
    Location
    London
    Posts
    515

    Re: or, also...

    Originally posted by Cimperiali
    Lothar "theGreat" Haensler gave an Api solution to this matter:
    & much more elegant solution than mine...!!

  11. #11
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Oh, you know...

    ...Lothar is Lothar.
    Once here we had a Top Ten based on points everybody could assign to answers...Lothar had stored so many points that he staied at Top of Top for more than one year after he left CodeGuru...
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  12. #12
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42
    Thank you !!!

    Iam using "Lothar Haensler API" currently.

    And also Iam trying with using the COM object. (to know the Core) it might help me in another cases also..


    Once again, thanks for the Share of Knowledge.

    bye
    Soundar
    your's
    Soundar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured