Results 1 to 5 of 5

Thread: Moving from Access to SqlServer - .Index Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    38

    Moving from Access to SqlServer - .Index Problem

    Hi.

    I've a VB6 application, which was based on an Access database. Now we're moving to sqlserver. We use ADODB, and when we use this piece of code:

    Dim TbTest as RecordSet

    Set TbTest = new Adodb.recordset
    TbTest.open "Custom", Curcnxni, adOpenStatic, adLockPessimistic, adCmdTableDirect

    TbTest.index = "PrimaryKey"

    It throws an error, property not supported. How does sqlserver handles indexes? This kind of index declaration is in many places in the code.

    Any help? Thanks in advance!

  2. #2
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: Moving from Access to SqlServer - .Index Problem


  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Moving from Access to SqlServer - .Index Problem

    Moved to database section

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    38

    Re: Moving from Access to SqlServer - .Index Problem

    Thanks for the Link amrita. Somehow it was self-explanatory.

    .index
    .seek

    Not supported by a sqlserver recordset, because in sqlserver we've a new philosophy, not bringing all the records over the network, only the needed. But, if i really wanted to use the .index and .seek, even if they are not the best option... isn't really there any solution?

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Moving from Access to SqlServer - .Index Problem

    It's not a new philosophy, or unique to SQL Server - even with Access you should not be returning all rows to your program, as not only is the database engine more efficient at searching than your program, but it also reduces the amount of memory and CPU usage (as well as network usage if apt), and is less likely to cause errors when multiple users are working with the same database.

    There is an alternative method suggested in the help, but that can't be recommended either, for the same reasons.

    What you should do is merge the .Open/.Index/.Seek rows into one, eg:
    Code:
      TbTest.open "SELECT * FROM Custom WHERE PrimaryKey = value", Curcnxni, adOpenStatic, adLockPessimistic, adCmdText
    ..or more readable (and easier to debug):
    Code:
    Dim strSQL as String
      strSQL = "SELECT * FROM Custom WHERE PrimaryKey = value" 
      TbTest.open strSQL, Curcnxni, adOpenStatic, adLockPessimistic, adCmdText

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