null value?

ssfftt

Well-known member
Joined
Oct 27, 2005
Messages
163
Programming Experience
1-3
[resolved]null value?

I am learning this case: http://www.startvbdotnet.com/ado/msaccess.aspx

I applied the code in the section of "Data Access using MSAccess" ---> "Sample Code" ---> "Code for retrieving records" ,
when i click on button1 at run time, it gives error: 'System.NullReferenceException'. and the line " dr.Close()" was highlighted.

can anyone help plz!
 
Last edited:
You probaby have error in retriving data. Try changing try ... catch block so it will catch your error:

VB.NET:
Catch (e As Exception)
MessageBox.Show(e.Message)
Finnaly
dr.Close()
cn.Close()
End Try
 
i put your code in, it says:

end of statement expected

'Message' is not a member of 'System.EventArgs'

Name 'Finally' is not declared
 
Hey,

Sorry to butt in here ManicCW,

Looks like e is already being used by an event handler you need to do the following to check for errors.

VB.NET:
Try

'Place the code which you think might be causing the error here..

Catch err as Exception

MessageBox.Show(err.Message)

End Try
 
thx BadgerByte, that was helpful.
the error is: could not find installable ISAM

what is this? how can i fix it?
 
Hey,

From the error described I'd take a guess that the problem is either with the access database file or your connection string, if you're using the exact code from the link you've shown do you have the access database "emp.mdb" at "c:\"?
 
You are right BadgerByte I did not pay attention to e argument but I thik it's understandable what I was trying to explain. I wrote that in a rush without testing, sorry. ssfftt please post your connection string and please change your nick :)
 
Hey,

Don't apologise Mr Manic, just thought it needed further explanation, I'm forever guilty of such things!

ssfftt, I've actually given the code a go and attached my solution files and the db file. It works fine as posted. If you've followed the steps exactly as shown and are recieving this error I'm going to guess it's a problem with the version of Access you've created the db with.

Hope this helps.
 

Attachments

  • BasicConnection.zip
    29.7 KB · Views: 33
thx you all, it worked fine for me now, just couldnt figure out why the exactly same code didnt work for me the other day but it works perfect today.

I also have concern on this part of code:

VB.NET:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

how come its not in my code window, do we need to code it or .NET generates it automatically?
 
Back
Top