Hi
I'm trying on a tabletennis applications which save playernames,playernpoints,startTime and EndTime into a sqlExpress table, I've also created in c#express.
The MatchTable contains following colums:
MatchID int (isIdentity)
PlayerName1 nvarchar(50)
PlayerName2 nvarchar(50)
PlayerPoints1 int
PlayerPoints2 int
MatchBegin datetime
MatchEnd datetime (here I want also the seconds)
For the playernames I'v attached 2 comboxes to the matchTablebindingsource.
How can I fill the table with the above informations
Many thanks
using
System;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;using
System.Diagnostics;namespace
WindowsApplication1{
public partial class Form1 : Form{
int Player1PointCount = 0; int Player2PointCount = 0; Stopwatch stopwatch = new Stopwatch(); public Form1(){
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e){
if (stopwatch.IsRunning){
if (e.KeyCode == Keys.Y)Player1PointCount++;
Player1PointsLabel.Text = Player1PointCount.ToString();
if (e.KeyCode == Keys.M)Player2PointCount++;
Player2PointsLabel.Text = Player2PointCount.ToString();
}
}
private void Points(){
if (Player1PointCount > 10){
if (Player1PointCount - Player2PointCount >= 2){
timer1.Enabled =
false;stopwatch.Stop();
MessageBox.Show("Player1 wins with " + Player1PointCount.ToString() + " Points");Player1PointCount = 0;
Player2PointCount = 0;
}
if (Player1PointCount > 9){
Player1PointsLabel.Left = -30;
Player1PointsLabel.Top = 9;
}
}
if (Player2PointCount > 10)
{
if (Player2PointCount - Player1PointCount >= 2){
timer1.Enabled =
false;stopwatch.Stop();
MessageBox.Show("Player2 wins with " + Player2PointCount.ToString() + " Points");Player1PointCount = 0;
Player2PointCount = 0;
}
}
}
private void button1_Click(object sender, EventArgs e){
if (stopwatch.IsRunning){
stopwatch.Stop();
button1.Text =
"Start"; string StartTime = DateTime.Now.ToString(); MessageBox.Show(StartTime);}
else{
stopwatch.Start();
button1.Text =
"Stop"; string StartTime = DateTime.Now.ToLongTimeString(); MessageBox.Show(StartTime);}
}
private void timer1_Tick(object sender, EventArgs e){
if (stopwatch.IsRunning){
TimeSpan ts = stopwatch.Elapsed; this.Text = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Points();
}
}
private void Form1_Load(object sender, EventArgs e){
// TODO: This line of code loads data into the 'pingPongDataSet.MatchTable' table. You can move, or remove it, as needed. this.matchTableTableAdapter.Fill(this.pingPongDataSet.MatchTable);}
private void matchTableBindingNavigatorSaveItem_Click(object sender, EventArgs e){
this.Validate(); this.matchTableBindingSource.EndEdit(); this.matchTableTableAdapter.Update(this.pingPongDataSet.MatchTable);}
}
}

Inserting ComboBoxText, StartTime and EndTime into SQL Express table
MudMike
Hi,
Is your problem solved If no then can you be clear in your problem definition
Thank you,
Bhanu.
dnhxx
I solved it with this code:
PingPongDataSet
.MatchTableRow newMatchTableRow =pingPongDataSet.MatchTable.NewMatchTableRow();
newMatchTableRow.Player1Name = PlayerNameComboBox1.Text;
newMatchTableRow.Player2Name = PlayerNameComboBox2.Text;
newMatchTableRow.Player1Points = Player1PointCount;
newMatchTableRow.Player2Points = Player2PointCount;
newMatchTableRow.MatchBegin = myStartTime;
newMatchTableRow.MatchEnd = myEndTime;
pingPongDataSet.MatchTable.Rows.Add(newMatchTableRow);
DataBindings.Clear();
bmoreno
hi,
when you find an answer for your question b4 anyone respond to you, post it and mark it as answer for your question , because it might help other ppl
best regards