NullReferenceException was unhandled

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1648 Views - Last Post: 06 April 2009 - 08:47 AM Rate Topic: -----

#16 Anthaas  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 98
  • Joined: 26-March 09

Re: NullReferenceException was unhandled

Posted 06 April 2009 - 08:00 AM

View PostMrWobbles, on 6 Apr, 2009 - 06:49 AM, said:

	Private Sub AEDFilm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Me.FilmTableTableAdapter.Fill(Me.DVDDatabaseDataSet.FilmTable)
		Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=|DataDirectory|\DVDDatabase.mdb")
		Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM Table1", con)
		con.Open()
		Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(myDA)
		mydataset = New DataSet()

				myDA = New OleDb.OleDbDataAdapter(cmd) '<--- Changed This

		myDA.Fill(mydataset, "FilmTable")
		datagridview1.DataSource = mydataset.Tables("FilmTable").DefaultView
		con.Close()
		con = Nothing
	End Sub
End Class


New error:

OleDbException was unhandled - The Microsoft Jet database engine cannot find the input table or query 'Table1'. Make sure it exists and that its name is spelled correctly."

This post has been edited by Anthaas: 06 April 2009 - 08:01 AM

Was This Post Helpful? 0
  • +
  • -

#17 Anthaas  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 98
  • Joined: 26-March 09

Re: NullReferenceException was unhandled

Posted 06 April 2009 - 08:47 AM

View PostAnthaas, on 6 Apr, 2009 - 07:00 AM, said:

View PostMrWobbles, on 6 Apr, 2009 - 06:49 AM, said:

	Private Sub AEDFilm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Me.FilmTableTableAdapter.Fill(Me.DVDDatabaseDataSet.FilmTable)
		Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=|DataDirectory|\DVDDatabase.mdb")
		Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM Table1", con)
		con.Open()
		Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(myDA)
		mydataset = New DataSet()

				myDA = New OleDb.OleDbDataAdapter(cmd) '<--- Changed This

		myDA.Fill(mydataset, "FilmTable")
		datagridview1.DataSource = mydataset.Tables("FilmTable").DefaultView
		con.Close()
		con = Nothing
	End Sub
End Class


New error:

OleDbException was unhandled - The Microsoft Jet database engine cannot find the input table or query 'Table1'. Make sure it exists and that its name is spelled correctly."


Ok, I sorted that, the Table in my SELECT bit was still called Table1 and not FilmTable. But now I have this error:

"NullReferenceException was unhandled - Object reference not set to an instance of an object."

on this line of code.

datagridview1.DataSource = mydataset.Tables("FilmTable").DefaultView

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2