dim Code:
  1. Imports System.Data.OleDb
  2.  
  3. Public Class highScore
  4.     Dim dbConnection As OleDb.OleDbConnection
  5.     Dim dbCommand As OleDb.OleDbCommand
  6.     Dim dbAdapter As OleDb.OleDbDataAdapter
  7.     Dim ConnectionString As String = "Provider= Microsoft.Jet.OLEDB.4.0;" & _
  8.     "Data Source = SSADatabase.mdb"
  9.     Dim dtHighScore As DataTable
  10.     Dim SelectedData As String = "highScore"
  11.  
  12.     Private Sub getData()
  13.         dbConnection = New OleDb.OleDbConnection(ConnectionString)
  14.         dbAdapter = New OleDb.OleDbDataAdapter
  15.         dtHighScore = New DataTable
  16.         dbCommand = New OleDb.OleDbCommand(SelectedData)
  17.         dbCommand.CommandType = CommandType.TableDirect
  18.         dbAdapter.SelectCommand = dbCommand
  19.         dbAdapter.SelectCommand.Connection = dbConnection
  20.         dbConnection.Open()
  21.         dbAdapter.Fill(dtHighScore)
  22.         DataGridView.DataSource = dtHighScore
  23.     End Sub
  24.  
  25.     Private Sub highScore_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  26.         getData()
  27.     End Sub
  28.  
  29.     Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
  30.         Dim objRow As DataRow
  31.         Dim tableName As String = "highScore"
  32.         Dim objDataSet As New DataSet
  33.         If txtName.Text = "" Then
  34.             MsgBox("You need to fill out your name")
  35.             Exit Sub
  36.         End If
  37.         Dim newAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM " & tableName & "", ConnectionString)
  38.         objDataSet.Clear()
  39.         newAdapter.FillSchema(objDataSet, SchemaType.Source, tableName)
  40.         newAdapter.Fill(objDataSet, tableName)
  41.         objRow = objDataSet.Tables(tableName).Rows.Find(objDataSet.Tables(tableName).Rows.Count + 1)
  42.         objRow.Item("Name") = txtName.Text   '' <----- This line here
  43.         objRow.Item("Score") = myTotalScore
  44.  
  45.     End Sub

Note the last 3rd line i get this error when i try to save data
Object reference not set to an instance of an object.
It never happens to me before and it works on a different application that i made.

My DB looks like this
ID = auto number & primary no
Name = Text
Score = number

What is going on???

Please help me!

T Chaiyaphan