Connecting Tech Pros Worldwide Forums | Help | Site Map

Question with udl and connection string does it work? TIA Sal

sal
Guest
 
Posts: n/a
#1: Nov 21 '05
Greets, All

Question with udl and connection string does it work?

I'm having problems with the code below I keep getting an error "Keyword
not supported 'File Name'"

I was just following app.dev cbt course and for some reason it doesn't
work for me does someone know what I doing wrong

Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBrowse.Click

With OpenFileDialog1
Dim response As String
Dim strConnect As String
.Filter = "UDL connection File(*.udl)|*.udl|All Files(*.*)|*.
*"
.FilterIndex = 1
.Title = " Select a UDL File"
If .ShowDialog() = DialogResult.OK Then
txtUDLFile.Text = .FileName

SqlConnection1.ConnectionString = String.Format("File
Name={0};", txtUDLFile.Text)

SqlConnection1.Open()
If SqlConnection1.State = ConnectionState.Open Then
Console.WriteLine("Connection opened successfully")
Else
Console.WriteLine("Connection could not be
established")
End If
SqlConnection1.Close()
SqlConnection1 = Nothing

response = Console.ReadLine()

End If
End With
End Sub



Here's the udl file contents below
[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=sppDb;Data Source=(local)\vsdotnet



I'm using VS.net 2003 using vb.net


TIA



Sahil Malik
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Question with udl and connection string does it work? TIA Sal


Yes the below will not work.

When specifying a udl file (which as you already know is nothing but a text
file), AND when you are using SqlConnection, the ConnectionString should be

"Integrated Security=SSPI;Persist Security Info=False;Initial
Catalog=sppDb;Data Source=(local)\vsdotnet"

i.e, start at Provider, ignore the provider key (because you are using
SqlConnection, you shouldn't specify provider), and the rest is useful.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik




"sal" <sal@spp.net> wrote in message
news:Xns959CF2B8458Dsalsppnet@216.77.188.18...[color=blue]
> Greets, All
>
> Question with udl and connection string does it work?
>
> I'm having problems with the code below I keep getting an error "Keyword
> not supported 'File Name'"
>
> I was just following app.dev cbt course and for some reason it doesn't
> work for me does someone know what I doing wrong
>
> Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnBrowse.Click
>
> With OpenFileDialog1
> Dim response As String
> Dim strConnect As String
> .Filter = "UDL connection File(*.udl)|*.udl|All Files(*.*)|*.
> *"
> .FilterIndex = 1
> .Title = " Select a UDL File"
> If .ShowDialog() = DialogResult.OK Then
> txtUDLFile.Text = .FileName
>
> SqlConnection1.ConnectionString = String.Format("File
> Name={0};", txtUDLFile.Text)
>
> SqlConnection1.Open()
> If SqlConnection1.State = ConnectionState.Open Then
> Console.WriteLine("Connection opened successfully")
> Else
> Console.WriteLine("Connection could not be
> established")
> End If
> SqlConnection1.Close()
> SqlConnection1 = Nothing
>
> response = Console.ReadLine()
>
> End If
> End With
> End Sub
>
>
>
> Here's the udl file contents below
> [oledb]
> ; Everything after this line is an OLE DB initstring
> Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
> Info=False;Initial Catalog=sppDb;Data Source=(local)\vsdotnet
>
>
>
> I'm using VS.net 2003 using vb.net
>
>
> TIA
>
>[/color]


Closed Thread