Solved

Opening a Sql database using VB6...

Posted on 1998-11-24
3
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

751 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