2 // System.Data.SqlClient.SqlConnectionStringBuilder.cs
5 // Sureshkumar T (tsureshkumar@novell.com)
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
33 using System.Collections.Generic;
34 using System.Collections.ObjectModel;
37 using System.Data.Common;
38 using System.ComponentModel;
40 namespace System.Data.SqlClient
42 [DefaultPropertyAttribute ("DataSource")]
44 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlConnectionStringBuilderConverter, " + Consts.AssemblySystem_Data)]
46 public sealed class SqlConnectionStringBuilder : DbConnectionStringBuilder
49 private const string DEF_APPLICATIONNAME = ".NET SqlClient Data Provider";
50 private const bool DEF_ASYNCHRONOUSPROCESSING = false;
51 private const string DEF_ATTACHDBFILENAME = "";
52 private const bool DEF_CONNECTIONRESET = true;
53 private const int DEF_CONNECTTIMEOUT = 15;
54 private const string DEF_CURRENTLANGUAGE = "";
55 private const string DEF_DATASOURCE = "";
56 private const bool DEF_ENCRYPT = false;
57 private const bool DEF_ENLIST = false;
58 private const string DEF_FAILOVERPARTNER = "";
59 private const string DEF_INITIALCATALOG = "";
60 private const bool DEF_INTEGRATEDSECURITY = false;
61 private const int DEF_LOADBALANCETIMEOUT = 0;
62 private const int DEF_MAXPOOLSIZE = 100;
63 private const int DEF_MINPOOLSIZE = 0;
64 private const bool DEF_MULTIPLEACTIVERESULTSETS = false;
65 private const string DEF_NETWORKLIBRARY = "";
66 private const int DEF_PACKETSIZE = 8000;
67 private const string DEF_PASSWORD = "";
68 private const bool DEF_PERSISTSECURITYINFO = false;
69 private const bool DEF_POOLING = true;
70 private const bool DEF_REPLICATION = false;
71 private const string DEF_USERID = "";
72 private const string DEF_WORKSTATIONID = "";
73 private const string DEF_TYPESYSTEMVERSION = "Latest";
74 private const bool DEF_TRUSTSERVERCERTIFICATE = false;
75 private const bool DEF_USERINSTANCE = false;
76 private const bool DEF_CONTEXTCONNECTION = false;
77 private const string DEF_TRANSACTIONBINDING = "Implicit Unbind";
81 private string _applicationName;
82 private bool _asynchronousProcessing;
83 private string _attachDBFilename;
84 private bool _connectionReset;
85 private int _connectTimeout;
86 private string _currentLanguage;
87 private string _dataSource;
88 private bool _encrypt;
90 private string _failoverPartner;
91 private string _initialCatalog;
92 private bool _integratedSecurity;
93 private int _loadBalanceTimeout;
94 private int _maxPoolSize;
95 private int _minPoolSize;
96 private bool _multipleActiveResultSets;
97 private string _networkLibrary;
98 private int _packetSize;
99 private string _password;
100 private bool _persistSecurityInfo;
101 private bool _pooling;
102 private bool _replication;
103 private string _userID;
104 private string _workstationID;
105 private bool _trustServerCertificate;
106 private string _typeSystemVersion;
107 private bool _userInstance;
108 private bool _contextConnection;
109 private string _transactionBinding;
111 private static Dictionary <string, string> _keywords; // for mapping duplicate keywords
112 private static Dictionary <string, object> _defaults;
116 public SqlConnectionStringBuilder () : this (String.Empty)
120 public SqlConnectionStringBuilder (string connectionString)
123 base.ConnectionString = connectionString;
126 static SqlConnectionStringBuilder ()
128 _keywords = new Dictionary <string, string> ();
129 _keywords ["APP"] = "Application Name";
130 _keywords ["APPLICATION NAME"] = "Application Name";
131 _keywords ["ATTACHDBFILENAME"] = "AttachDbFilename";
132 _keywords ["EXTENDED PROPERTIES"] = "Extended Properties";
133 _keywords ["INITIAL FILE NAME"] = "Initial File Name";
134 _keywords ["TIMEOUT"] = "Connect Timeout";
135 _keywords ["CONNECT TIMEOUT"] = "Connect Timeout";
136 _keywords ["CONNECTION TIMEOUT"] = "Connect Timeout";
137 _keywords ["CONNECTION RESET"] = "Connection Reset";
138 _keywords ["LANGUAGE"] = "Current Language";
139 _keywords ["CURRENT LANGUAGE"] = "Current Language";
140 _keywords ["DATA SOURCE"] = "Data Source";
141 _keywords ["SERVER"] = "Data Source";
142 _keywords ["ADDRESS"] = "Data Source";
143 _keywords ["ADDR"] = "Data Source";
144 _keywords ["NETWORK ADDRESS"] = "Data Source";
145 _keywords ["ENCRYPT"] = "Encrypt";
146 _keywords ["ENLIST"] = "Enlist";
147 _keywords ["INITIAL CATALOG"] = "Initial Catalog";
148 _keywords ["DATABASE"] = "Initial Catalog";
149 _keywords ["INTEGRATED SECURITY"] = "Integrated Security";
150 _keywords ["TRUSTED_CONNECTION"] = "Integrated Security";
151 _keywords ["MAX POOL SIZE"] = "Max Pool Size";
152 _keywords ["MIN POOL SIZE"] = "Min Pool Size";
153 _keywords ["MULTIPLEACTIVERESULTSETS"] = "MultipleActiveResultSets";
154 _keywords ["ASYNCHRONOUS PROCESSING"] = "Asynchronous Processing";
155 _keywords ["ASYNC"] = "Async";
156 _keywords ["NET"] = "Network Library";
157 _keywords ["NETWORK"] = "Network Library";
158 _keywords ["NETWORK LIBRARY"] = "Network Library";
159 _keywords ["PACKET SIZE"] = "Packet Size";
160 _keywords ["PASSWORD"] = "Password";
161 _keywords ["PWD"] = "Password";
162 _keywords ["PERSISTSECURITYINFO"] = "Persist Security Info";
163 _keywords ["PERSIST SECURITY INFO"] = "Persist Security Info";
164 _keywords ["POOLING"] = "Pooling";
165 _keywords ["UID"] = "User ID";
166 _keywords ["USER"] = "User ID";
167 _keywords ["USER ID"] = "User ID";
168 _keywords ["WSID"] = "Workstation ID";
169 _keywords ["WORKSTATION ID"] = "Workstation ID";
170 _keywords ["USER INSTANCE"] = "User Instance";
171 _keywords ["CONTEXT CONNECTION"] = "Context Connection";
172 _keywords ["TRANSACTION BINDING"] = "Transaction Binding";
173 _keywords ["FAILOVER PARTNER"] = "Failover Partner";
174 _keywords ["REPLICATION"] = "Replication";
175 _keywords ["TRUSTSERVERCERTIFICATE"] = "TrustServerCertificate";
176 _keywords ["LOAD BALANCE TIMEOUT"] = "Load Balance Timeout";
177 _keywords ["TYPE SYSTEM VERSION"] = "Type System Version";
179 _defaults = new Dictionary<string, object> ();
180 _defaults.Add("Data Source", DEF_DATASOURCE);
181 _defaults.Add("Failover Partner", DEF_FAILOVERPARTNER);
182 _defaults.Add("AttachDbFilename", DEF_ATTACHDBFILENAME);
183 _defaults.Add("Initial Catalog", DEF_INITIALCATALOG);
184 _defaults.Add("Integrated Security", DEF_INTEGRATEDSECURITY);
185 _defaults.Add("Persist Security Info", DEF_PERSISTSECURITYINFO);
186 _defaults.Add("User ID", DEF_USERID);
187 _defaults.Add("Password", DEF_PASSWORD);
188 _defaults.Add("Enlist", DEF_ENLIST);
189 _defaults.Add("Pooling", DEF_POOLING);
190 _defaults.Add("Min Pool Size", DEF_MINPOOLSIZE);
191 _defaults.Add("Max Pool Size", DEF_MAXPOOLSIZE);
192 _defaults.Add("Asynchronous Processing", DEF_ASYNCHRONOUSPROCESSING);
193 _defaults.Add("Connection Reset", DEF_CONNECTIONRESET);
194 _defaults.Add("MultipleActiveResultSets", DEF_MULTIPLEACTIVERESULTSETS);
195 _defaults.Add("Replication", DEF_REPLICATION);
196 _defaults.Add("Connect Timeout", DEF_CONNECTTIMEOUT);
197 _defaults.Add("Encrypt", DEF_ENCRYPT);
198 _defaults.Add("TrustServerCertificate", DEF_TRUSTSERVERCERTIFICATE);
199 _defaults.Add("Load Balance Timeout", DEF_LOADBALANCETIMEOUT);
200 _defaults.Add("Network Library", DEF_NETWORKLIBRARY);
201 _defaults.Add("Packet Size", DEF_PACKETSIZE);
202 _defaults.Add("Type System Version", DEF_TYPESYSTEMVERSION);
203 _defaults.Add("Application Name", DEF_APPLICATIONNAME);
204 _defaults.Add("Current Language", DEF_CURRENTLANGUAGE);
205 _defaults.Add("Workstation ID", DEF_WORKSTATIONID);
206 _defaults.Add("User Instance", DEF_USERINSTANCE);
207 _defaults.Add("Context Connection", DEF_CONTEXTCONNECTION);
208 _defaults.Add("Transaction Binding", DEF_TRANSACTIONBINDING);
210 #endregion // Constructors
213 [DisplayNameAttribute ("Application Name")]
214 [RefreshPropertiesAttribute (RefreshProperties.All)]
215 public string ApplicationName {
216 get { return _applicationName; }
218 base ["Application Name"] = value;
219 _applicationName = value;
223 [DisplayNameAttribute ("Asynchronous Processing")]
224 [RefreshPropertiesAttribute (RefreshProperties.All)]
225 public bool AsynchronousProcessing {
226 get { return _asynchronousProcessing; }
228 base ["Asynchronous Processing"] = value;
229 _asynchronousProcessing = value;
234 [Editor ("System.Windows.Forms.Design.FileNameEditor, " + Consts.AssemblySystem_Design,
235 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
237 [Editor ("Microsoft.VSDesigner.Data.Design.DBParametersEditor, " + Consts.AssemblyMicrosoft_VSDesigner,
238 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
240 [DisplayNameAttribute ("AttachDbFilename")]
241 [RefreshPropertiesAttribute (RefreshProperties.All)]
242 public string AttachDBFilename {
243 get { return _attachDBFilename; }
245 base ["AttachDbFilename"] = value;
246 _attachDBFilename = value;
250 [DisplayNameAttribute ("Connection Reset")]
251 [RefreshPropertiesAttribute (RefreshProperties.All)]
252 public bool ConnectionReset {
253 get { return _connectionReset; }
255 base ["Connection Reset"] = value;
256 _connectionReset = value;
260 [DisplayNameAttribute ("Connect Timeout")]
261 [RefreshPropertiesAttribute (RefreshProperties.All)]
262 public int ConnectTimeout {
263 get { return _connectTimeout; }
265 base ["Connect Timeout"] = value;
266 _connectTimeout = value;
270 [DisplayNameAttribute ("Current Language")]
271 [RefreshPropertiesAttribute (RefreshProperties.All)]
272 public string CurrentLanguage {
273 get { return _currentLanguage; }
275 base ["Current Language"] = value;
276 _currentLanguage = value;
280 [DisplayNameAttribute ("Data Source")]
281 [RefreshPropertiesAttribute (RefreshProperties.All)]
283 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter, " + Consts.AssemblySystem_Data)]
285 public string DataSource {
286 get { return _dataSource; }
288 base ["Data Source"] = value;
293 [DisplayNameAttribute ("Encrypt")]
294 [RefreshPropertiesAttribute (RefreshProperties.All)]
295 public bool Encrypt {
296 get { return _encrypt; }
298 base ["Encrypt"] = value;
303 [DisplayNameAttribute ("Enlist")]
304 [RefreshPropertiesAttribute (RefreshProperties.All)]
306 get { return _enlist; }
308 base ["Enlist"] = value;
313 [DisplayNameAttribute ("Failover Partner")]
314 [RefreshPropertiesAttribute (RefreshProperties.All)]
316 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter, " + Consts.AssemblySystem_Data)]
318 public string FailoverPartner {
319 get { return _failoverPartner; }
321 base ["Failover Partner"] = value;
322 _failoverPartner = value;
326 [DisplayNameAttribute ("Initial Catalog")]
327 [RefreshPropertiesAttribute (RefreshProperties.All)]
329 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlInitialCatalogConverter, " + Consts.AssemblySystem_Data)]
331 public string InitialCatalog {
332 get { return _initialCatalog; }
334 base ["Initial Catalog"] = value;
335 _initialCatalog = value;
339 [DisplayNameAttribute ("Integrated Security")]
340 [RefreshPropertiesAttribute (RefreshProperties.All)]
341 public bool IntegratedSecurity {
342 get { return _integratedSecurity; }
344 base ["Integrated Security"] = value;
345 _integratedSecurity = value;
349 public override bool IsFixedSize {
353 public override object this [string keyword] {
355 string mapped = MapKeyword (keyword);
356 if (base.ContainsKey (mapped))
357 return base [mapped];
359 return _defaults [mapped];
361 set {SetValue (keyword, value);}
364 public override ICollection Keys {
366 List<string> keys = new List<string>();
367 keys.Add("Data Source");
368 keys.Add("Failover Partner");
369 keys.Add("AttachDbFilename");
370 keys.Add("Initial Catalog");
371 keys.Add("Integrated Security");
372 keys.Add("Persist Security Info");
374 keys.Add("Password");
377 keys.Add("Min Pool Size");
378 keys.Add("Max Pool Size");
379 keys.Add("Asynchronous Processing");
380 keys.Add("Connection Reset");
381 keys.Add("MultipleActiveResultSets");
382 keys.Add("Replication");
383 keys.Add("Connect Timeout");
385 keys.Add("TrustServerCertificate");
386 keys.Add("Load Balance Timeout");
387 keys.Add("Network Library");
388 keys.Add("Packet Size");
389 keys.Add("Type System Version");
390 keys.Add("Application Name");
391 keys.Add("Current Language");
392 keys.Add("Workstation ID");
393 keys.Add("User Instance");
394 keys.Add("Context Connection");
395 keys.Add("Transaction Binding");
396 ReadOnlyCollection<string> coll = new ReadOnlyCollection<string>(keys);
401 [DisplayNameAttribute ("Load Balance Timeout")]
402 [RefreshPropertiesAttribute (RefreshProperties.All)]
403 public int LoadBalanceTimeout {
404 get { return _loadBalanceTimeout; }
406 base ["Load Balance Timeout"] = value;
407 _loadBalanceTimeout = value;
411 [DisplayNameAttribute ("Max Pool Size")]
412 [RefreshPropertiesAttribute (RefreshProperties.All)]
413 public int MaxPoolSize {
414 get { return _maxPoolSize; }
416 base ["Max Pool Size"] = value;
417 _maxPoolSize = value;
421 [DisplayNameAttribute ("Min Pool Size")]
422 [RefreshPropertiesAttribute (RefreshProperties.All)]
423 public int MinPoolSize {
424 get { return _minPoolSize; }
426 base ["Min Pool Size"] = value;
427 _minPoolSize = value;
431 [DisplayNameAttribute ("MultipleActiveResultSets")]
432 [RefreshPropertiesAttribute (RefreshProperties.All)]
433 public bool MultipleActiveResultSets {
434 get { return _multipleActiveResultSets; }
436 base ["Multiple Active Resultsets"] = value;
437 _multipleActiveResultSets = value;
441 [DisplayNameAttribute ("Network Library")]
442 [RefreshPropertiesAttribute (RefreshProperties.All)]
444 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+NetworkLibraryConverter, " + Consts.AssemblySystem_Data)]
446 public string NetworkLibrary {
447 get { return _networkLibrary; }
449 base ["Network Library"] = value;
450 _networkLibrary = value;
454 [DisplayNameAttribute ("Packet Size")]
455 [RefreshPropertiesAttribute (RefreshProperties.All)]
456 public int PacketSize {
457 get { return _packetSize; }
459 base ["Packet Size"] = value;
464 [DisplayNameAttribute ("Password")]
465 [PasswordPropertyTextAttribute (true)]
466 [RefreshPropertiesAttribute (RefreshProperties.All)]
467 public string Password {
468 get { return _password; }
470 base ["Password"] = value;
475 [DisplayNameAttribute ("Persist Security Info")]
476 [RefreshPropertiesAttribute (RefreshProperties.All)]
477 public bool PersistSecurityInfo {
478 get { return _persistSecurityInfo; }
480 base ["Persist Security Info"] = value;
481 _persistSecurityInfo = value;
485 [DisplayNameAttribute ("Pooling")]
486 [RefreshPropertiesAttribute (RefreshProperties.All)]
487 public bool Pooling {
488 get { return _pooling; }
490 base ["Pooling"] = value;
495 [DisplayNameAttribute ("Replication")]
496 [RefreshPropertiesAttribute (RefreshProperties.All)]
497 public bool Replication {
498 get { return _replication; }
500 base ["Replication"] = value;
501 _replication = value;
505 [DisplayNameAttribute ("User ID")]
506 [RefreshPropertiesAttribute (RefreshProperties.All)]
507 public string UserID {
508 get { return _userID; }
510 base ["User Id"]= value;
515 public override ICollection Values {
517 List<object> values = new List<object>();
518 values.Add(_dataSource);
519 values.Add(_failoverPartner);
520 values.Add(_attachDBFilename);
521 values.Add(_initialCatalog);
522 values.Add(_integratedSecurity);
523 values.Add(_persistSecurityInfo);
525 values.Add(_password);
527 values.Add(_pooling);
528 values.Add(_minPoolSize);
529 values.Add(_maxPoolSize);
530 values.Add(_asynchronousProcessing);
531 values.Add(_connectionReset);
532 values.Add(_multipleActiveResultSets);
533 values.Add(_replication);
534 values.Add(_connectTimeout);
535 values.Add(_encrypt);
536 values.Add(_trustServerCertificate);
537 values.Add(_loadBalanceTimeout);
538 values.Add(_networkLibrary);
539 values.Add(_packetSize);
540 values.Add(_typeSystemVersion);
541 values.Add(_applicationName);
542 values.Add(_currentLanguage);
543 values.Add(_workstationID);
544 values.Add(_userInstance);
545 values.Add(_contextConnection);
546 values.Add(_transactionBinding);
547 ReadOnlyCollection<object> coll = new ReadOnlyCollection<object>(values);
552 [DisplayNameAttribute ("Workstation ID")]
553 [RefreshPropertiesAttribute (RefreshProperties.All)]
554 public string WorkstationID {
555 get { return _workstationID; }
557 base ["Workstation Id"] = value;
558 _workstationID = value;
562 [DisplayNameAttribute ("TrustServerCertificate")]
563 [RefreshProperties (RefreshProperties.All)]
564 public bool TrustServerCertificate {
565 get { return _trustServerCertificate; }
567 base ["Trust Server Certificate"] = value;
568 _trustServerCertificate = value;
572 [DisplayNameAttribute ("Type System Version")]
573 [RefreshProperties (RefreshProperties.All)]
574 public string TypeSystemVersion {
575 get { return _typeSystemVersion; }
577 base ["Type System Version"] = value;
578 _typeSystemVersion = value;
582 [DisplayNameAttribute ("User Instance")]
583 [RefreshProperties (RefreshProperties.All)]
584 public bool UserInstance {
585 get { return _userInstance; }
587 base ["User Instance"] = value;
588 _userInstance = value;
592 [RefreshPropertiesAttribute (RefreshProperties.All)]
593 [DisplayNameAttribute ("Context Connection")]
594 public bool ContextConnection {
595 get { return _contextConnection; }
597 base ["Context Connection"] = value;
598 _contextConnection = value;
601 #endregion // Properties
606 _applicationName = DEF_APPLICATIONNAME;
607 _asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
608 _attachDBFilename = DEF_ATTACHDBFILENAME;
609 _connectionReset = DEF_CONNECTIONRESET;
610 _connectTimeout = DEF_CONNECTTIMEOUT;
611 _currentLanguage = DEF_CURRENTLANGUAGE;
612 _dataSource = DEF_DATASOURCE;
613 _encrypt = DEF_ENCRYPT;
614 _enlist = DEF_ENLIST;
615 _failoverPartner = DEF_FAILOVERPARTNER;
616 _initialCatalog = DEF_INITIALCATALOG;
617 _integratedSecurity = DEF_INTEGRATEDSECURITY;
618 _loadBalanceTimeout = DEF_LOADBALANCETIMEOUT;
619 _maxPoolSize = DEF_MAXPOOLSIZE;
620 _minPoolSize = DEF_MINPOOLSIZE;
621 _multipleActiveResultSets= DEF_MULTIPLEACTIVERESULTSETS;
622 _networkLibrary = DEF_NETWORKLIBRARY;
623 _packetSize = DEF_PACKETSIZE;
624 _password = DEF_PASSWORD;
625 _persistSecurityInfo = DEF_PERSISTSECURITYINFO;
626 _pooling = DEF_POOLING;
627 _replication = DEF_REPLICATION;
628 _userID = DEF_USERID;
629 _workstationID = DEF_WORKSTATIONID;
630 _trustServerCertificate = DEF_TRUSTSERVERCERTIFICATE;
631 _typeSystemVersion = DEF_TYPESYSTEMVERSION;
632 _userInstance = DEF_USERINSTANCE;
633 _contextConnection = DEF_CONTEXTCONNECTION;
634 _transactionBinding = DEF_TRANSACTIONBINDING;
637 public override void Clear ()
643 public override bool ContainsKey (string keyword)
645 keyword = keyword.ToUpper ().Trim ();
646 if (_keywords.ContainsKey (keyword))
647 return base.ContainsKey (_keywords [keyword]);
651 public override bool Remove (string keyword)
653 if (!ContainsKey (keyword))
655 this [keyword] = null;
659 [MonoNotSupported ("")] // Note that base.ShouldSerialize() is called but not implemented
660 public override bool ShouldSerialize (string keyword)
662 if (!ContainsKey (keyword))
664 keyword = keyword.ToUpper ().Trim ();
665 // Assuming passwords cannot be serialized.
666 if (_keywords [keyword] == "Password")
668 return base.ShouldSerialize (_keywords [keyword]);
671 public override bool TryGetValue (string keyword, out object value)
673 if (! ContainsKey (keyword)) {
674 value = String.Empty;
677 return base.TryGetValue (_keywords [keyword.ToUpper ().Trim ()], out value);
680 #endregion // Methods
682 #region Private Methods
683 private string MapKeyword (string keyword)
685 keyword = keyword.ToUpper ().Trim ();
686 if (! _keywords.ContainsKey (keyword))
687 throw new ArgumentException("Keyword not supported :" + keyword);
688 return _keywords [keyword];
691 private void SetValue (string key, object value)
694 throw new ArgumentNullException ("key cannot be null!");
696 string mappedKey = MapKeyword (key);
698 switch (mappedKey.ToUpper ().Trim ()) {
699 case "APPLICATION NAME" :
701 _applicationName = DEF_APPLICATIONNAME;
702 base.Remove (mappedKey);
704 this.ApplicationName = value.ToString ();
706 case "ATTACHDBFILENAME" :
707 throw new NotImplementedException ("Attachable database support is " +
709 case "CONNECT TIMEOUT" :
711 _connectTimeout = DEF_CONNECTTIMEOUT;
712 base.Remove (mappedKey);
714 this.ConnectTimeout = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
716 case "CONNECTION LIFETIME" :
718 case "CONNECTION RESET" :
720 _connectionReset = DEF_CONNECTIONRESET;
721 base.Remove (mappedKey);
723 this.ConnectionReset = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
725 case "CURRENT LANGUAGE" :
727 _currentLanguage = DEF_CURRENTLANGUAGE;
728 base.Remove (mappedKey);
730 this.CurrentLanguage = value.ToString ();
732 case "CONTEXT CONNECTION" :
734 _contextConnection = DEF_CONTEXTCONNECTION;
735 base.Remove (mappedKey);
737 this.ContextConnection = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
741 _dataSource = DEF_DATASOURCE;
742 base.Remove (mappedKey);
744 this.DataSource = value.ToString ();
748 _encrypt = DEF_ENCRYPT;
749 base.Remove (mappedKey);
750 }else if (DbConnectionStringBuilderHelper.ConvertToBoolean(value))
751 throw new NotImplementedException("SSL encryption for"
752 + " data sent between client and server is not"
757 _enlist = DEF_ENLIST;
758 base.Remove (mappedKey);
759 } else if ( ! DbConnectionStringBuilderHelper.ConvertToBoolean(value))
760 throw new NotImplementedException("Disabling the automatic"
761 + " enlistment of connections in the thread's current"
762 + " transaction context is not implemented.");
764 case "INITIAL CATALOG" :
766 _initialCatalog = DEF_INITIALCATALOG;
767 base.Remove (mappedKey);
769 this.InitialCatalog = value.ToString ();
771 case "INTEGRATED SECURITY" :
773 _integratedSecurity = DEF_INTEGRATEDSECURITY;
774 base.Remove (mappedKey);
776 this.IntegratedSecurity = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
778 case "MAX POOL SIZE" :
780 _maxPoolSize = DEF_MAXPOOLSIZE;
781 base.Remove (mappedKey);
783 this.MaxPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
785 case "MIN POOL SIZE" :
787 _minPoolSize = DEF_MINPOOLSIZE;
788 base.Remove (mappedKey);
790 this.MinPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
792 case "MULTIPLEACTIVERESULTSETS":
794 _multipleActiveResultSets = DEF_MULTIPLEACTIVERESULTSETS;
795 base.Remove (mappedKey);
796 } else if ( DbConnectionStringBuilderHelper.ConvertToBoolean (value))
797 throw new NotImplementedException ("MARS is not yet implemented!");
799 case "ASYNCHRONOUS PROCESSING" :
801 _asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
802 base.Remove (mappedKey);
804 this.AsynchronousProcessing = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
806 case "NETWORK LIBRARY" :
808 _networkLibrary = DEF_NETWORKLIBRARY;
809 base.Remove (mappedKey);
811 if (!value.ToString ().ToUpper ().Equals ("DBMSSOCN"))
812 throw new ArgumentException ("Unsupported network library.");
813 this.NetworkLibrary = value.ToString ().ToLower ();
816 case "LOAD BALANCE TIMEOUT":
817 // TODO: what is this?
821 _packetSize = DEF_PACKETSIZE;
822 base.Remove (mappedKey);
824 this.PacketSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
828 _password = DEF_PASSWORD;
829 base.Remove (mappedKey);
831 this.Password = value.ToString ();
833 case "PERSIST SECURITY INFO" :
835 _persistSecurityInfo = DEF_PERSISTSECURITYINFO;
836 base.Remove (mappedKey);
837 } else if (DbConnectionStringBuilderHelper.ConvertToBoolean (value))
838 throw new NotImplementedException ("Persisting security info" +
839 " is not yet implemented");
843 _pooling = DEF_POOLING;
844 base.Remove (mappedKey);
846 this.Pooling = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
850 _userID = DEF_USERID;
851 base.Remove (mappedKey);
853 this.UserID = value.ToString ();
855 case "USER INSTANCE" :
857 _userInstance = DEF_USERINSTANCE;
858 base.Remove (mappedKey);
860 this.UserInstance = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
862 case "WORKSTATION ID" :
864 _workstationID = DEF_WORKSTATIONID;
865 base.Remove (mappedKey);
867 this.WorkstationID = value.ToString ();
869 case "TRANSACTION BINDING":
870 // TODO: what is this?
873 throw new ArgumentException("Keyword not supported :" + key);
876 #endregion // Private Methods