Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Packaging and Deployment / Distributioin 2

Status
Not open for further replies.

Trudye

Programmer
Sep 4, 2001
932
US
If your VB program depends on a Access table do you have to write a script (or a batch pgm) to load the table on the Users machine and then create an ODBC entry for it?

Also can anyone recommend a GOOD book on packaging and deployment (with lots of examples)? One that shows you how to write a script or a batch pgm.

Thanks much
Trudye
 
The Access 'table' itself doesn't get loaded onto the users machine. Either you provide the entire database (via Package & Deployment) or have the database reside on the network somewhere.

Regarding the ODBC entry, there are only two methods I know of to create a System DSN: 1. Enter it manually (sucks) or 2. Do it programatically (nice...).

Here is a little code to do just that:
Code:
Option Explicit

'  Place this code in *.bas module.
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
   (ByVal hwndParent As Long, ByVal fRequest As Long, _
   ByVal lpszDriver As String, ByVal lpszAttributes As String) _
   As Long

Private Const ODBC_ADD_SYS_DSN = 4

Public Function CreateAccessDSN(DSNName As String, _
  DatabaseFullPath As String) As Boolean

'PURPOSE: 'CREATES A SYSTEM DSN FOR AN ACCESS DATABASE
'PARAMETERS: 'DSNName = DSN Name
             'DatabaseFullPath = Full Path to .mdb file
'RETURNS: True if successful, false otherwise
'EXAMPLE: CreateAccessDSN "MyDSN", "C:\MyDb.mdb"

    Dim sAttributes As String
    
    'TEST TO SEE IF FILE EXISTS: YOU CAN REMOVE IF YOU
    'DON'T WANT IT
    If Dir(DatabaseFullPath) = "" Then Exit Function
    
sAttributes = "DSN=" & DSNName & Chr(0)
sAttributes = sAttributes & "DBQ=" & DatabaseFullPath & Chr(0)
CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)", _
   sAttributes)

End Function

With this code, the user won't have to enter their own System DSN:)
 
Thank you Mr. Sheffield for answering my question. I have a few follow-up questions.

During the packaging process I was asked if I wanted to include any additional objects. I included my (.mdb) file (even tho .mdb was not listed in the filetype drop down. When I loaded the pgm on another PC and executed the pgm was unable to locate the database.

My question is: Does this mean the ODBC entry must be present even with the .mdb file is bundled into the package? And if thats true what path do I give the ODCB?

thanks again
Trudye
 
I tried the code you gave me, it looks good. However the compiler could not locate the "CreateDSN" routine in the following statment. OR did I do something wrong?

CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)", _

Thank you so much for your help
Trudye

Also since I have your attention. How do I get my setup pgm to create a shortcut and place it on the desktop? Also (I know I'm waring out my welcom aren't I), the system is creating an entry in the Start (popup) menu, but its not pointing to my .exe file. What should I pay close attention to when I am using the PDW to correct this problem?
 
Mr. Sheffield:

I tried the code you gave me, it looks good. However the compiler could not locate the "CreateDSN" routine in the following statment. OR did I do something wrong?

CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)", _

Thank you so much for your help
Trudye

Also since I have your attention. How do I get my setup pgm to create a shortcut and place it on the desktop? Also (I know I'm waring out my welcom aren't I), the system is creating an entry in the Start (popup) menu, but its not pointing to my .exe file. What should I pay close attention to when I am using the PDW to correct this problem?
 
Sorry. Try this. Sorry I don't have more answers:-(

Code:
Public Function CreateDSN(Driver As String, Attributes As _
  String) As Boolean

'PURPOSE: CREATES A SYSTEM DSN
'PARAMETERS: 'Driver = DriverName
'ATTRIBUTES: 'Attributes; varies as a function
             'of the Driver

    CreateDSN = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, _
      Driver, Attributes)
        
End Function

--Enjoy....
 
OK. I was compiled and ready to go and then it dawned on me what do I have to do to get my new .bas file to execute on the Users machine?

Do I have to write a batch pgm or vbScript? And if I do what do I have to do in the pkg and Deploy scenario to get the batch or vbscript to execute other than include them?

Loss in LA
Trudye
 
Surley you can just use it in your app as an if else :

If dsn exists Then
'thats good we don't need to do anything
Else
'oh you don't have the dsn, well lets make it
End If Regards

Big Bad Dave

davidbyng@hotmail.com
 
What Dave means is.

IF (CreateAccessDSN("MyDsn","C:\MyDb.mdb") THEN
msgBox "DSN Created" 'or whatever code you want

ELSE
Msgbox "DSN not Created" 'or whatever

END IF
Give a man a program and tomorrow he will be hungry.
Teach a man to program and he will never hunger again.
--Sunr¿se

 
What I meant was you could put the if-check in the heart of your app so it is always checking if the dsn exists (It can be usefull if the dsn gets deleted by the user etc) You won't need to excute any sperate bas files when installing. Regards

Big Bad Dave

davidbyng@hotmail.com
 
DUH!

I don't know why that didn't occur to me, I guess I went into PANIC mode, I am sooooo close to being done.

Thanks a lot to all of you BigBadDave, Sunrise, Sheffield, and John Yingling.

May all your bugs be visible. Have a Great Year!

Trudye
 
Thanks again Guys it worked. I now have a completely Deplorable (oops I mean Deployable)package.

If I haven't worn out my welcome. Does anyone know how to get the setup pgm to create an icon on the desktop?

ALl the Best
Trudye
 
You need a different set-up application like InstallShield, SetupFactory etc Regards

Big Bad Dave

davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top