HighTechTalks DotNet Forums  

object reference not set to an instance of an object

Dotnet Framework (ODBC.net) microsoft.public.dotnet.framework.odbcnet


Discuss object reference not set to an instance of an object in the Dotnet Framework (ODBC.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Barret Bonden
 
Posts: n/a

Default object reference not set to an instance of an object - 02-23-2005 , 04:00 PM






I get "object reference not set to an instance of an object " when running
the code below. Just tying to learn; took the code from a book. Tested the
connection string, and that's OK.

Private Sub Buttonj1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim con As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=F:\old
d\splash\SPLASH.MDB;Persist Security Info=False "

Dim sSQL As String

sSQL = "select * from company"

Dim objConn As New OleDb.OleDbConnection(con)

Dim da As New OleDb.OleDbDataAdapter(sSQL, con)

Dim ds As New DataSet("test")

Dim dv As DataView

Try

objConn.Open()

Catch myexception As System.Exception

Windows.Forms.MessageBox.Show(myexception.Message)

End Try



If objConn.State = ConnectionState.Open Then

Try

da.Fill(ds, "test")

objConn.Close()

Dim ot As DataTable

ot = ds.Tables("company")



dv = ot.DefaultView

TextBox1.DataBindings.Add("text", dv, "company")

Catch myexception As System.Exception

Windows.Forms.MessageBox.Show(myexception.Message)

End Try

End If

End Sub

End Class



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.