Solved

Opening a Sql database using VB6...

Posted on 1998-11-24
3
314 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now