Please help
I keep getting the following error: "Object reference not set to an instance of an object." for the code DataRow myRow = myTable.NewRow();
string connectionString = @"data source = GERHARDVDM28-PC; initial catalog = RacerUI; integrated security=SSPI";
string commandString = @"SELECT * FROM Entries";
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, connectionString);
SqlCommandBuilder scb = new SqlCommandBuilder(dataAdapter);
DataSet racerUIDataSet = new DataSet();
DataTable myTable = racerUIDataSet.Tables["Entries"];
this.entriesTableAdapter.Fill(this.racerUIDataSet.Entries);
DataRow myRow = myTable.NewRow();
myRow[0] = RacerName;
myRow[1] = BikeManufacturer;
myRow[2] = RaceNumber;
myRow[3] = Team;
myTable.Rows.Add(myRow);
dataAdapter.Update(racerUIDataSet, "Entries");
racerUIDataSet.AcceptChanges();

Suthish NairRank #92 · 22.8K reputationPosted Dec 9, 2010, 10:37 AM EST
if(myTable != null && myTable.Tables[0].Rows.Count != 0)
{
DataRow myRow = myTable.NewRow();
}
Gerhard van der Merwe24 reputationPosted Dec 11, 2010, 5:53 AM EST
I am now able to add data to the Table but when I get to one specific textbox with numeric input I get the following error when compiling:
Unable to cast object of type 'System.Windows.Forms.TextBox' to type 'System.IConvertible'.Couldn't store
Gerhard van der Merwe24 reputationPosted Dec 11, 2010, 8:19 AM EST
public void RaceNumber_TextChanged(object sender, EventArgs e)
{
Decimal Value = int.Parse(RaceNumber.Text);
if (this.RaceNumber.Text == "" || this.RaceNumber.Text == null)
Value = 0;
else
Value = Convert.ToDecimal(this.RaceNumber.Text);
}
Suthish NairRank #92 · 22.8K reputationPosted Dec 11, 2010, 9:22 AM EST