Crear archivo de instalaci贸n

Juan
05 de Julio del 2004
Hola, mi problema es que necesito que durante la instalaci贸n de mi programa se cree un origen de datos ODBC en windows que luego utilizar谩 mi programa para acceder a una base de datos. Como podr铆a hacerlo?, no se que programa utilizar para crear el archivo de instalaci贸n, como puedo hacer todo esto?
Muchas gracias.

sdemingo
05 de Julio del 2004
Hola,

mmm yo hice algo as铆...

Utiliza el setup factory para hacer tu instalador de la aplicaci贸n, bd, mdac, etc...

Luego, en el setup factory le puedes decir que ejecute alg煤n programa al acabar la instalaci贸n, entonces le dices que ejecute un programa que hayas hecho tu en el que creas la conexi贸n ODBC en VB.

Espero que te sirva, a mi me funcion贸

salu2
sdemingo

Juan
05 de Julio del 2004
Muchas gracias, pero no se como crear el origen de datos desde visual basic, yo lo hago siempre a mano, si me puedes indicar como hacerlo te lo agradecer铆a mucho.
gracias.

sdemingo
05 de Julio del 2004
Ejemplo paso a paso
Inicie un Nuevo proyecto.
En la ficha Avanzado del cuadro de di谩logo Opciones en el men煤 Herramientas, establezca un Argumento de Compilaci贸n condicional que se denomina WIN32 igual que 1 si utiliza 32 bits Visual Basic 4.0 o 0 si utiliza Visual Basic 4.0 de 16 bits.
Agregue dos CommandButtons al formulario predeterminado.
Agregue el c贸digo siguiente al General Declarations: Option Explicit

'Constant Declaration
Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const vbAPINull As Long = 0& ' NULL Pointer

'Function Declare
#If WIN32 Then

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
#Else
Private Declare Function SQLConfigDataSource Lib "ODBCINST.DLL" _
(ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal _
lpszDriver As String, ByVal lpszAttributes As String) As Integer
#End If

Agregue el c贸digo siguiente al evento Click de Comando1: #If WIN32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String

'Set the driver to SQL Server because it is most common.
strDriver = "SQL Server"
'Set the attributes delimited by null.
'See driver documentation for a complete
'list of supported attributes.
strAttributes = "SERVER=SomeServer" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=Temp DSN" & Chr$(0)
strAttributes = strAttributes & "DSN=DSN_TEMP" & Chr$(0)
strAttributes = strAttributes & "DATABASE=pubs" & Chr$(0)
'To show dialog, use Form1.Hwnd instead of vbAPINull.
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, _
strDriver, strAttributes)
If intRet Then
MsgBox "DSN Created"
Else
MsgBox "Create Failed"
End If

Agregue el c贸digo siguiente al evento Click de Comando2: #If WIN32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String

'Set the driver to SQL Server because most common.
strDriver = "SQL Server"
'Set the attributes delimited by null.
'See driver documentation for a complete list of attributes.
strAttributes = "DSN=DSN_TEMP" & Chr$(0)
'To show dialog, use Form1.Hwnd instead of vbAPINull.
intRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, _
strDriver, strAttributes)
If intRet Then
MsgBox "DSN Deleted"
Else
MsgBox "Delete Failed"
End If

Ejecute el proyecto.
Haga clic en Comando1 para agregar un DSN que se denomina DSN_TEMP.
Haga clic en Comando2 para quitar el DSN que se denomina DSN_TEMP.