Re: escaping semi colon in connectionstring
- From: "Brendan Reynolds" <brenreyn@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Jun 2005 19:17:07 +0100
This works for me ...
Public Sub TestSub()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Integrated Security=SSPI;Persist Security Info=False;" & _
"Initial Catalog=" & Chr$(34) & "test;name" & Chr$(34) & _
";Data Source=(local)"
cnn.Open
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = cnn
.Source = "SELECT * FROM dbo.authors"
.Open
Debug.Print .Fields(0).Value
.Close
End With
cnn.Close
End Sub
--
Brendan Reynolds (MVP)
"Ajey" <ajey5@xxxxxxxxxxx> wrote in message
news:ue3NQ6YdFHA.3488@xxxxxxxxxxxxxxxxxxxxxxx
>I tried using double quotes. I doesn't work.
>
>
> "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxxxx> wrote in message
> news:uahMbvmcFHA.1040@xxxxxxxxxxxxxxxxxxxxxxx
>> Ajey wrote on Thu, 16 Jun 2005 14:42:35 +0530:
>>
>>> Hi,
>>> I created a database having ; in name e.g. abc;def
>>> Now, while connecting to this database using ADO I am getting
>>> "Invalid connection string attribute" error. How can I escape semicolon
>>> in
>>> connection string.
>>>
>>> Connection string:
>>>
>>> Provider=SQLOLEDB;Server=S1;Database=abc;def;Trusted_Connection=NO;User
>>> Id=a;Password=a;
>>>
>>
>> From
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp
>>
>> "To include values that contain a semicolon, single-quote character, or
>> double-quote character, the value must be enclosed in double quotes"
>>
>> so try
>>
>> Provider=SQLOLEDB;Server=S1;Database="abc;def";Trusted_Connection=NO;User
>> Id=a;Password=a;
>>
>>
>> Dan
>>
>
>
.
- Follow-Ups:
- Re: escaping semi colon in connectionstring
- From: Ajey
- Re: escaping semi colon in connectionstring
- References:
- escaping semi colon in connectionstring
- From: Ajey
- Re: escaping semi colon in connectionstring
- From: Daniel Crichton
- Re: escaping semi colon in connectionstring
- From: Ajey
- escaping semi colon in connectionstring
- Prev by Date: Re: escaping semi colon in connectionstring
- Next by Date: Re: Unable to Update Data table in Access Database via ADO
- Previous by thread: Re: escaping semi colon in connectionstring
- Next by thread: Re: escaping semi colon in connectionstring
- Index(es):
Relevant Pages
|
|