locked
Using Visual Studio (VB) to request (utilising MySQL scripting) the current date from Host MySQL server RRS feed

  • Question

  • Hi,

    Can anyone guide me on how to (using VB) to request the date from a MySQL server and return it to use in a variable?. I am trying to request a reliable time from my server but i didn't want to get caught up with user access or ports (i.e. asking the windows server or the internet). I have a good MySQL server connection and assume that it should a fairly easy thing to do as I already have a connection.

    I already know that i could obtain it by creating a dummy table and store a timestamp and update and return as i need it. But as this would involve a select, store, select then read everytime, i wanted to keep things efficient. Can anyone help?

    Cheers in advance

    The Mexican


    • Edited by The Mexican Monday, February 10, 2014 11:09 PM explaination change
    • Moved by Carl Cai Tuesday, February 11, 2014 6:52 AM (from vb.net) issues related to third-party are not supported
    Monday, February 10, 2014 10:55 PM

Answers

  • Doesn't MySQL have Stored Procedures? I believe it does have the ability to created Stored Procedures.  So you make a MYSQL Stored Procedure that's going to return the Date and Time from the MySQL database server and return the Date and Time as an output parameter from the Stored Procedure 

    You would make the call to the Stored Procedure through VB.NET.

    There should be plenty of examples on Bing or Google on how to make a MySQL Stored Procedure and how to make the call from a VB.NET program to MySQL to execute the Stored Procedure.

    • Marked as answer by The Mexican Tuesday, February 11, 2014 10:17 AM
    Tuesday, February 11, 2014 2:14 AM

All replies

  • What is wrong with getting a the time from your local computer using DateTime.Now?  Most computers use an internet time from a very very very accurate time standard so your computer time should be very very very close to the server time.

    jdweng

    Tuesday, February 11, 2014 2:08 AM
  • Doesn't MySQL have Stored Procedures? I believe it does have the ability to created Stored Procedures.  So you make a MYSQL Stored Procedure that's going to return the Date and Time from the MySQL database server and return the Date and Time as an output parameter from the Stored Procedure 

    You would make the call to the Stored Procedure through VB.NET.

    There should be plenty of examples on Bing or Google on how to make a MySQL Stored Procedure and how to make the call from a VB.NET program to MySQL to execute the Stored Procedure.

    • Marked as answer by The Mexican Tuesday, February 11, 2014 10:17 AM
    Tuesday, February 11, 2014 2:14 AM
  • First, issues about MySQL are not supported here.

     >>But as this would involve a select, store, select then read everytime, i wanted to keep things efficient<<

    I don't think it need to create a dummy table and bla bla.

    Just use this simple query:

    select now()

    Have a nice day. : )

    remember make the reply as answer and vote the reply as helpful if it helps.

    Tuesday, February 11, 2014 2:21 AM
  • Hi,

    Can anyone guide me on how to (using VB) to request the date from a MySQL server and return it to use in a variable?. I am trying to request a reliable time from my server but i didn't want to get caught up with user access or ports (i.e. asking the windows server or the internet). I have a good MySQL server connection and assume that it should a fairly easy thing to do as I already have a connection.

    I already know that i could obtain it by creating a dummy table and store a timestamp and update and return as i need it. But as this would involve a select, store, select then read everytime, i wanted to keep things efficient. Can anyone help?

    Cheers in advance

    The Mexican


    Hi,

    Welcome to MSDN.

    As Risa said that issues related to MySql are not supported here, I would suggest you consider posting this

    issue in the website of the publisher.

    If you find any reply is helpful, you could make it as answer.

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 11, 2014 6:51 AM
  • I wanted to stay away from this as the code is used on multiple PC's that are not on a domain. It will cause problems if the user changes the date. I didn't want to rely on the internet for the time if I can get the SQL server to do it for me. Also if the internet connection goes, so will the program. Thanks Though
    Tuesday, February 11, 2014 10:11 AM
  • Doesn't get simpler than that! I wish :-)  I wanted to stay away from this type of code as this is used on multiple PC's that are not on a domain. It will cause huge problems if the user changes the date. Thanks though.
    Tuesday, February 11, 2014 10:14 AM
  • Brilliant, I haven't used stored procedures before. I had a quick look and that is exactly what I was looking for. Thanks a lot!!!!!!

    Tuesday, February 11, 2014 10:17 AM