Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Opening a Sql database using VB6...

Posted on 1998-11-24
3
Medium Priority
?
332 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 300 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

972 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