Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem With ConnectionStringBuilder
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01447146
Message ID:
01447153
Vues:
25
>>In my DataAccess class I have a private method called GetConnectionString to generate the connection string based on property values. I'm trying to use it to connect to an Access database. In this method is a switch which is evaluated based on the InvariantName. For the OleDb option I have:
>>
>>
>>
>>DbConnectionStringBuilder csb = _Factory.CreateConnectionStringBuilder();
>>
>>.
>>.
>>.
>>
>>case "System.Data.OleDb":
>>    if (_Provider != "")
>>    {
>>        csb.Add("Provider", _Provider);
>>    }
>>    if (_DataSource != "")
>>    {
>>        csb.Add("Data Source", _DataSource);
>>    }
>>    if (_InitialCatalog != "")
>>    {
>>        csb.Add("Initial Catalog", _InitialCatalog);
>>    }
>>    if (_TrustedConnection)
>>    {
>>        csb.Add("Integrated Security", "SSPI");
>>    }
>>    else
>>    {
>>        if (_UserName != "")
>>        {
>>            csb.Add("User Id", _UserName);
>>        }
>>
>>        if (_Password != "")
>>        {
>>            csb.Add("pwd", _Password);
>>        }
>>    }
>>
>>    break;
>>
>>
>>
>>Then outside the switch I have:
>>
>>
>>return csb.ConnectionString;
>>
>>
>>When I step to this line and hover over 'csb', I see
>>
Provider=Microsoft.Jet.OLEDB.4.0;Data Source="M:\APEX Master Database.mdb";Integrated Security=SSPI
>>
>>When I hover over 'ConnectionString' I see:
>>
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"M:\\APEX Master Database.mdb\";Integrated Security=SSPI
>>
>>Notice the extra slashes before and after the database name.
>
>I think you're just mis-interpreting what you're seeing: The additional backslashes as escaping the quotation marks and the existing backslash.

ya, you're right.

Thanks
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform