none
How to insert actual datetime with seconds into sql express database ?

    Question

  • Hi

    On buttonclick i want to create a variable with startTime. Clicking the same button again should create a second variable with endTime.
    Clicking the savebutton then should create a new row in my dataset and insert the two datetime variables.

    I've created a MatchTable with following colums:


    MatchID int (isIdentity)
    PlayerName1 nvarchar(50)
    PlayerName2 nvarchar(50)
    PlayerPoints1 int
    PlayerPoints2 int
    MatchBegin datetime
    MatchEnd datetime

    I'm working with VC#Express

    Thank you very much

    Thursday, May 11, 2006 6:58 AM

All replies

  • create one variable with name

    DateTime

    beginTime;

     

    DateTime endTime;
    in class
    now add one button with text as "Start"
    and add following code in  button1_Click event 

    if

    (button1.Text == "Start")

    {

    button1.Text =

    "Stop";

    beginTime =

    DateTime.Now;

    }

     

    else if (button1.Text == "Start")

    {

    button1.Text =

    "Start";

    endTime =

    DateTime.Now;

     

    // insert database query here

    }

     

    else

    {

     

    MessageBox.Show("Invalid state");

    }

    Monday, July 06, 2009 11:37 AM