Results 1 to 14 of 14

Thread: Anyone khow which method to open database is fastest ?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    44

    Anyone khow which method to open database is fastest ?

    Dear All

    I'am using VB6 and SQL 2000.

    Anyone know which method of open database and recorset is fastest ??


    Best Regards

    Long

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    What are these "methods" you refer to?

    Uhm.. use ADO, if that answers your question.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    44
    I use ADO, i mean is open connection and recorset.
    Sample open connection to SQL :
    1. Conn.Open "Driver={sql server};server=SvrName;database=DBName;uid=sa;pwd="

    2. Use ODBC.

    My Question is
    Which method is fastest or anyone can give me some choice ?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    DSN-Less is the fastest, and should be preferred. It doesn't have that extra layer like in ODBC and isn't slow like DSN.

    connection strings

  5. #5
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    OLEDB is supposed to be faster than ODBC:

    Code:
    "Provider=SQLOLEDB;Server=ServerName;Database=DBName;Trusted_Connection=Yes;"
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    44
    Thanks for helping me.




    Best Regards

    Long

  7. #7
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Disreguard
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  8. #8

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    44
    Dear

    I've a question

    a. dim Conn as New ADODB.Connection

    b. dim Conn as ADODB.Connection
    set Conn = NEW ADODB.Connection

    Which different of point a with b ?


    Best Ragards


    Long

  9. #9
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Speed wise there is no difference since the object is not really created untill the object is refrenced or a set statemnet is used.

    When you use "Dim Myobj as NEW Class" the object is not created it is only refrenced. This is called "Early Binding". It helps when you are compiling the project because if there is an error with the Class it will show up then, but not is you use Late binding.

    Late Binding would be
    Dim MyObject as Class
    Set MyObject = NEW Class

    They are both created at the same speed. But i think late binding uses less resources.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  10. #10

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    44
    I want to make a small program client-server, where client ( at place A ) can access data at server ( at place B ).
    I use ADO and Lease Line Connection, this is my sample code :


    Dim Conn as New ADODB.Connection
    dim Rec as New ADODB.Recordset

    'Open Connection
    Conn.Open "Driver={SQL Server};" & _
    "Server=xxx.xxx.xxx.xxx;" & _
    "Address=xxx.xxx.xxx.xxx,1433;" & _
    "Network=DBMSSOCN;" & _
    "Database=myDatabaseName;" & _
    "Uid=myUsername;" & _
    "Pwd=myPassword;"

    'Open Recordset

    Rec.Open "Select * from MyTable",Conn,AdOpenKeySet,AdLockoptismistic,AdCmdText
    If Rec.recordcount > 0 then
    'Do something
    endif

    When i try to debug my program, at position of open recordset is need a long time to open a table.

    Anyone can tell me or can give a comment about my coding ?




    Long

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I think it's normal for it to take a long time, IF the computer B is a remote terminal. If it's on the same network, you can use it's UNC name... like \\computername.

  12. #12
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Originally posted by Arc
    Speed wise there is no difference since the object is not really created untill the object is refrenced or a set statemnet is used.

    When you use "Dim Myobj as NEW Class" the object is not created it is only refrenced. This is called "Early Binding". It helps when you are compiling the project because if there is an error with the Class it will show up then, but not is you use Late binding.

    Late Binding would be
    Dim MyObject as Class
    Set MyObject = NEW Class

    They are both created at the same speed. But i think late binding uses less resources.
    No - both those are early binding, which is faster because it compiles the COM stuff into your app.

    Late binding is
    VB Code:
    1. Dim obj as [b]Object[b] 'the "Object" keyword, not any object
    2. Set obj = CreateObject("ADODB.Command")

    Thus, in late-binding, nothing is known about the object until run-time. If the VB6 IDE gives you Intellisense for an object, chances are it will be early bound.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  13. #13
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    also:

    Dim MyObject as Class
    Set MyObject = NEW Class

    is faster too
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  14. #14

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    44
    Dear Mendhak


    Can you give me a detail how to use a UNC Name ?


    Best Regards

    Long

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