SQL Server Performance

C# addRow and data, HELP!

Discussion in 'SQL Server 2008 General DBA Questions' started by Gerhardvdm28, Dec 9, 2010.

  1. Gerhardvdm28 New Member

    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();
  2. satya Moderator

    Welcome to the forums
    For me it looks more like a C# problem than the SQL, if you are able to connect to the SQL instance via other tools then its for sure a C# driver issue.
    See KBA http://support.microsoft.com/kb/810098 is any help.

Share This Page