Results 1 to 9 of 9

Thread: VB Class Library Project and Multiple Instances

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19

    VB Class Library Project and Multiple Instances

    Hi,

    i´m new to .Net and so i have this problem. I have a Class Library Project and ASP.Net.

    My Prob:
    Every Internet User uses the same Instance of the VB Project ????

    Example:
    User1: click ASP Page and uses a instance of the VB Project, the VB Project opens data from ADO
    User2: makes the same and i get for example the error, that the database is already opened
    => so i tested it, and both users use the same instance of the VB Project.

    How can i disable this ?

    In VB6 an ActiveX DLL always is a new instance and so you have no problem.

    Thanx in advance
    Oliver

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    I think how it works is for each user a new instance of the compiled dll is created. Now for the DB error, maybe you did'nt close your connection. Are you using ADO or ADO.NET?
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    @DevGrp
    thanks for the fast response.

    At the moment i use this:
    Public con As ADODB.Connection
    Public odbpath As String

    Sub dbopen(ByVal cdbpath As String)
    con = CreateObject("ADODB.Connection")
    con.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & odbpath & ";Jet OLEDBatabase Password=xxxx")
    End Sub

    Sub dbclose()
    con.Close()
    con = Nothing
    End Sub

    I first tried it with:
    Public con as New ADODB.Connection()

    But then i had a lot more problems, so i use createobject inside the dboben sub. In the Project i have a reference to the ADODB from .NET.

    So what would i need to change ? And who can i create a new instance for the dll for every user ? At the moment i'm using in the ASP.NET pages:
    Dim oControl2 As New DLLProject.DLLClass()

    Thanks
    Oliver

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Ok, with ADO I forgot I lot of stuff. I stopped using ADO when I switch over to .NET. ADO.NET is leaps and bounds better than ADO.

    Tell me exactly what you are trying to do and I'll see if I can give you some guidance. Aslo I suggest that you invest in a good ADO.NET book, you'll thank me later.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    Here is what i want to do:

    1. Have a VB Class Library Project with ADO
    2. ASP.NET Pages

    The User logs on:
    1. ASP.NET creates an instance of VB (Dim ocontrol as New dllproject.dllclass() )
    2. VB opens a connection to access
    3. read all userdatas from the DB
    4. closes the DB and sends the results to ASP

    Additional VB has several functions for editing, moving,etc. data. At the moment i'm using the connection object with recordsets (from VB6), as you seen in my post below.

    So in VB6 it was like that:
    1. Make COM-DLL
    2. ASP : Server.CreateObject(dllproject.dllclass)
    3. and now every user has its own instance and own variables and connections

    Now in VB.NET:
    1. Problem: every user uses the same instance, although i tell it with dim ocontrol as New dllproject.dllclass() to create a new one (or is that wrong?).
    2. If this is "only" an ADO Problem, i can switch to ADO.Net, if you can tell me what would be the best solution for me (DataReader, DataAdapter, OleDBConnection, DataSet, CommandBuilder, etc.) ?
    3. I read http://msdn.microsoft.com/library/de...adonetbest.asp and now i don't really know what to use and how. It would be super, if you can help me out, because this instancing problem is ...

    What book can you recommend ? But because the problem is urgent, i need to solve it without a book at the moment.

    thanks
    Oliver

  6. #6
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Ok, what I would use is ADO.NET. Now if you just presenting the data to the user, you should use a DataReader, since its very fast. If you are going to be editing that data, then a dataset is what you need.

    I'll write an example when I get home later.

    BTW a very good ADO.NET book is ADO.NET Core Reference by David Scheppa (MS Press) and Progmatic ADO.NET by Shawn Wildermuth (Addison Wesly). I recommend anyone doing .NET DB programming to get these two books quick. They'll save you a ton of time.
    Last edited by DevGrp; May 4th, 2003 at 03:15 PM.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    thanks again

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    have you already wrote an example ?

  9. #9
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Ok sorry for taking so long. I've been trying to write the demo, but I keep getting and error when I use Access. Apparently I have to set permissions for the DB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width