Hi all:
Is it possible to return a value from a UDL in code? This is what I have (written as DLL)
I'm trying to return the ConnectionString from the UDL to the parent app.
The DLL code works fine in the application and even as a DLL, but I cannot seem to capture the string before the UDL file is closed through the Process.
It does, however, save the UDL properly.
Any help will be greatly appreciated.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
Is it possible to return a value from a UDL in code? This is what I have (written as DLL)
Code:
Public Shared Function CreateUDL(ByVal FilePathString As String) As String
Dim SW As System.IO.StreamWriter
Dim SR As System.IO.StreamReader
Dim Fs As System.IO.FileStream
Dim FileName As String
Dim ConnectionString As String
Dim Line As String
Dim Proc As System.Diagnostics.Process = New System.Diagnostics.Process
Dim SD As System.Windows.Forms.SaveFileDialog = New System.Windows.Forms.SaveFileDialog
With SD
.AddExtension = True
.InitialDirectory = FilePathString 'System.Windows.Forms.Application.StartupPath & "\UDL\"
.Filter = "Universal Data Links|*.udl"
.Title = "Save As..."
End With
If SD.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
If SD.FileName <> "" Then
FileName = SD.FileName
If Dir(FileName) <> "" Then
Proc.StartInfo.FileName = FileName
Proc.Start()
Exit Function
End If
Fs = New System.IO.FileStream(FileName, _
System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.None)
Fs.Close()
Proc.StartInfo.FileName = FileName
Proc.Start()
End If
End If
SR = New System.IO.StreamReader(FileName)
Do
Line = SR.ReadLine()
If VB.Left(Line, 3) = "Pro" Then
ConnectionString = Line
End If
Loop Until Line Is Nothing
SR.Close()
Return ConnectionString
End Function
I'm trying to return the ConnectionString from the UDL to the parent app.
Code:
Dim UDL As clsUDL.clsUDL = New clsUDL.clsUDL
Dim s As String
Dim i As Integer
s = UDL.CreateUDL(System.Windows.Forms.Application.StartupPath & "\UDL\")
MsgBox(s)
The DLL code works fine in the application and even as a DLL, but I cannot seem to capture the string before the UDL file is closed through the Process.
It does, however, save the UDL properly.
Any help will be greatly appreciated.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.