Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Opening a Sql database using VB6...

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 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