Visual Basic - Necesito crear DSN en tiempo de ejecucion

Life is soft - evento anual de software empresarial
 
Vista:

Necesito crear DSN en tiempo de ejecucion

Publicado por Joel (30 intervenciones) el 18/10/2001 16:21:38
Necesito crear lo mismo que hago dentro del ODBC y creo un dsn en el panel de control , pero en tiempo de ejecucion.
gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Necesito crear DSN en tiempo de ejecucion

Publicado por isidroalmaguer (288 intervenciones) el 18/10/2001 23:41:10
puedes usar un api SQLConfigDataSource, te paso el ejemplo

Sub RegistrarDSN()
' rutina que crea la DSN si no esta instalada en la maquina del
' usuario
' Ing. Isidro Almaguer de la Rosa, 14/sept/2001
Dim intRet As Integer
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=tuservidor" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=desc de tu BD" & Chr$(0)
strAttributes = strAttributes & "DSN=tuDSN" & Chr$(0)
strAttributes = strAttributes & "DATABASE=TuBD" & Chr$(0)
'To show dialog, use Form1.Hwnd instead of vbAPINull.
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, _
strDriver, strAttributes)
If intRet Then
MsgBox "DSN creada con exito..."
Else
MsgBox "No se pudo crear DSN..."
End If
End Sub

declaracion de la api en un modulo

' para creacion de DSN
'Constant Declaration
Const ODBC_ADD_DSN = 1 ' Add data source, user DSN
Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Const ODBC_REMOVE_DSN = 3 ' Remove data source
Const vbAPINull As Long = 0 '& amp ' NULL Pointer
Const ODBC_ADD_SYS_DSN = 4 ' Add data source, system DSN

Declare Function SQLConfigDataSource Li
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar