Create, Delete Or Edit An Odbc Dsn From Lotusscript (Or Vb)

With the release of NotesSQL 2.06 you run create a silent installation when you
distribute your Notes apps. The problem has been creating a DSN so users can
access the database via ODBc (for Reporting).
This script will create, delete or edit the DSN for you, and it works in VB
Option Explicit

Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As
Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes
As String) As Long

Const ODBC_ADD_DSN = 1 ' Add data source
Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Const ODBC_REMOVE_DSN = 3 ' Remove data source

' to customize this script, modify the attributes DSN = YourName, Server =
YourServer, Database = YourDBPath
' don't forget to modify the final message box.

Dim dbDriver As String
Dim dbAttributes As String
Dim result As Integer

dbDriver = "Lotus NotesSQL Driver (*.nsf)"
dbAttributes = "DSN=Reports" & Chr$(0) _
& "Description=Reports" & Chr$(0) _
& "Server=Server1" & Chr$(0) _
& "Database=somedir\test.nsf" & Chr$(0) _
& "KeepTmpIdx=0" & Chr(0) _
& "MapSpecialChars=Y" & Chr(0) _
& "MaxLongVarcharLen=512" & Chr(0) _
& "MaxRels=20" & Chr(0) _
& "MaxStmtLen=8192" & Chr(0) _
& "MaxSubquery=20" & Chr(0) _
& "MaxVarcharLen=254" & Chr(0) _
& "ShowImplicitFlds=0" & Chr(0) _
& "ThreadTimeout=60" & Chr(0) & Chr(0)

result = SQLConfigDataSource(0, ODBC_ADD_DSN, dbDriver, dbAttributes)
If (False = result) Then
MsgBox "There was an error establishing the connection. You will have
to do it manually.", 16, "Failure"
' Else
' MsgBox "Data Source Name ""ISNOTESSQL"" configured."
End If

End Sub

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.