Jump to content
Xtreme .Net Talk

CzechMan

Members
  • Posts

    4
  • Joined

  • Last visited

CzechMan's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. PS: I changed the MyConn.Dispose() MyConn = Nothing for MyCMD.SelectCommand.Connection.Close() hoping it would help, but that's not really a solution.
  2. Thanks Guys. I think I'm getting the hang of it. I've managed to get rid of the first problem by removing the MyCMD.Dispouse line. Now for the 2nd problem nothing I do seems to help :( There is only one active DataReader at the time, and I do close all of them. The thing is that the error can show up on any page (that accesses the DB) no matter how coded, for example this morning I go the error on this page: Call OPEN_DB() Dim MyRead As OleDb.OleDbDataReader Dim MyCMD As New OleDb.OleDbDataAdapter("sp_hc_NEWS_VIEW", MyConn) MyCMD.SelectCommand.CommandType = CommandType.StoredProcedure MyCMD.SelectCommand.Parameters.Add("@ID", OleDb.OleDbType.Integer).Value = sID MyRead = MyCMD.SelectCommand.ExecuteReader() If Not MyRead.Read = False Then TITLE = MyRead.GetString(0) ARTICLE = MyRead.GetString(1) sDATE = MyRead.GetDateTime(2).ToShortDateString ACTIVE = CONVERT_TXT(MyRead.GetInt32(3).ToString) ANAME = MyRead.GetString(4) End If MyRead.Close() MyCMD.SelectCommand.Connection.Close() Page.DataBind() Any ideas what else could be wrong ? The error was: System.NullReferenceException: Object reference not set to an instance of an object. Line 43: End If Line 44: MyRead.Close() > Line 45: MyConn.Dispose() Line 46: MyConn = Nothing Line 47: Page.DataBind()
  3. I don't think you can connect to Access on one machine from another machine. You can do that with MS SQL since it allows remote connection but not with Access.
  4. Hello, I think my question is more or less about how to properly dispose of objects I've used. I'm coming over from ASP 3.0 where I've learned to dispose of everything I don't need, so I do the same thing in VB.NET, though lately as my project grows I think I'm fighting with the Garbage Collection. I can click on a page where I access the DB and get an error like the one below (the exact error varies but most of the time it's either one of those mentioned) then I can referesh the page and everything works just fine. So it leads me to believe that the GC is kicking in at times where I'm dispousing of some objects (Readers, OleDbCommand, OleDbConnection etc.). What's the proper way of dispousing of ojects and is that what's causing my problems ? In most VB.NET examples people don't dispouse of objects so I guess I should do the same ? Thanks for your time. Exception Details: System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first. Source Error: Line 65: MyCMD = New OleDb.OleDbCommand(SQL, MyConn) Line 66: MyRead = MyCMD.ExecuteReader > Line 67: MyCMD.Dispose() Line 68: While Not MyRead.Read = False Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 56: MyCMD = Nothing Line 57: dRepeater.DataSource = DS > Line 58: MyConn.Dispose() Line 59: MyConn = Nothing Line 60: dRepeater.DataBind()
×
×
  • Create New...