Solved

Opening a Sql database using VB6...

Posted on 1998-11-24
3
325 Views
Last Modified: 2013-12-25
Here's the thing, we've created a sql db by upsizing an access db, we then created a connection to this database in vb6, now how do we open this new db? Opendatabase command with some reference too the connection we created?
Any info was be much appreciated.
                                -Buffett
0
Comment
Question by:buffett111398
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
cymbolic earned 100 total points
ID: 1497796
Once you go to SQL Server, your best bet is to dump dao and the Jet database engine, and go via ODBC and RDO/ADO to the SQL Server database.  DAO carries with it some peculiar operating characteristics, like bringing whole tables down to your workstation for processing, and automatically encapsulating a process within a single transacton, etc.  There are locking contention problems to be faced in dao as well, some out of your control, since the engine makes some of your processing decisions for you, and not all are optimal decisions.

I recommend you get your hands on the latest version of "HItchiker's Guide to Visual Basic and SQL server" from MS Press, by W. R. Vaughn.  This will give you a comprehensive working knowldge of your options in this environment.

Regarding ways to do it, Here's some code in RDO that works:
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1497797
Public gEn                  As rdoEnvironment   'rdoEngine
Public gCnSrc               As rdoConnection    'Source Database
Public gCnTgt               As rdoConnection    'Target Database
Public gerrored As Boolean
Public gRs As rdoResultset       'shared main level resultset
Public gSQL as String       'shared SQL String

Public Function OpenSourceDb(Optional bPrompt As Boolean) As Boolean
'  Purpose: Opens the Migration Source database  (CDB)
'  Created: 06/04/97 - Moved from InitDataSources()
' Modified: 11/12/97 - Changed to Function returning success or failure
'----------------------------------------------------------------------------------------------
On Error GoTo OpenSourceDb_Err

'Prompt for DSN information?
If IsMissing(bPrompt) Then
    Set gCnSrc = gEn.OpenConnection(vbNullString, rdDriverCompleteRequired, False, "DSN=CDB_35")
Else
    Set gCnSrc = gEn.OpenConnection(vbNullString, rdDriverPrompt, False, "DSN=CDB_35")
End If
gCnSrc.QueryTimeout = 600
OpenSourceDb = True
Exit Function

OpenSourceDb_Err:
    LogErr
    OpenSourceDb = False
End Function
Public Sub RsSrc(rs As rdoResultset)
On Error GoTo eRsSrc
FMigWiz.MousePointer = vbHourglass
Set rs = gCnSrc.OpenResultset(gSql, rdOpenForwardOnly, rdConcurReadOnly)
gSql = vbNullString
glReads = glReads + 1
FMigWiz.MousePointer = vbNormal
Exit Sub
eRsSrc:
 LogErr
End Sub

'then to Actually do something:
private sub Doit
gSql = "SELECT * FROM PATIENT"
RsSrc gRs

Do Until gRs.EOF    'Data to work with?
    'work with data
     var=grs(#) or var=gRs!FldName, etc
    gRs.MoveNext
loop
gRs.CLose
End Sub
   
0
 

Author Comment

by:buffett111398
ID: 1497798
Thanks, a little overwhelming, but we'll look into it.
                                           -Buffett
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question