Modified:
branches/1.0/mysqlclient/MySqlError.cs
branches/1.0/mysqlclient/Types/MySqlDateTime.cs
branches/1.0/mysqlclient/common/SharedMemoryStream.cs
branches/1.0/mysqlclient/common/SocketStream.cs
branches/1.0/mysqlclient/dataadapter.cs
branches/1.0/mysqlclient/docs/MySqlCommand.xml
branches/1.0/mysqlclient/docs/MySqlConnection.xml
branches/1.0/mysqlclient/docs/MySqlDataAdapter.xml
branches/1.0/mysqlclient/docs/MySqlDataReader.xml
branches/1.0/mysqlclient/docs/MySqlTransaction.xml
branches/1.0/mysqlclient/parameter_collection.cs
branches/1.0/mysqlclient/transaction.cs
branches/1.0/mysqlclient/zlib/Deflate.cs
branches/1.0/mysqlclient/zlib/SupportClass.cs
branches/1.0/mysqlclient/zlib/ZInputStream.cs
branches/1.0/mysqlclient/zlib/ZOutputStream.cs
branches/1.0/mysqlclient/zlib/ZStream.cs
branches/1.0/mysqlclient/zlib/ZStreamException.cs
branches/1.0/mysqlclient/zlib/Zlib.cs
Log:
1. some more cleanups
2. fixed some documentation ambiguities
3. made ZLib classes internal so they would not show in docs
Modified: branches/1.0/mysqlclient/MySqlError.cs
===================================================================
--- branches/1.0/mysqlclient/MySqlError.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/MySqlError.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -67,6 +67,9 @@
}
};
+ /// <summary>
+ /// Provides a reference to error codes returned by MySQL.
+ /// </summary>
public enum MySqlErrorCode
{
/* ER_HASHCHK=1000,
@@ -92,6 +95,9 @@
ER_CHECKREAD 1020
ER_DISK_FULL 1021
*/
+ /// <summary>
+ /// There is already a key with the given values.
+ /// </summary>
DuplicateKey = 1022,
/* ER_ERROR_ON_CLOSE 1023
@@ -103,6 +109,9 @@
ER_FORM_NOT_FOUND 1029
ER_GET_ERRNO 1030
ER_ILLEGAL_HA 1031*/
+ /// <summary>
+ /// The specified key was not found.
+ /// </summary>
KeyNotFound = 1032,
/* ER_NOT_FORM_FILE 1033
ER_NOT_KEYFILE 1034
@@ -132,7 +141,13 @@
ER_WRONG_VALUE_COUNT 1058
ER_TOO_LONG_IDENT 1059
ER_DUP_FIELDNAME 1060*/
+ /// <summary>
+ /// Duplicate Key Name
+ /// </summary>
DuplicateKeyName = 1061,
+ /// <summary>
+ /// Duplicate Key Entry
+ /// </summary>
DuplicateKeyEntry = 1062,
/* ER_WRONG_FIELD_SPEC 1063
@@ -203,9 +218,21 @@
ER_FUNCTION_NOT_DEFINED 1128
ER_HOST_IS_BLOCKED 1129
*/
+ /// <summary>
+ /// The given host is not allowed to connect
+ /// </summary>
HostNotPrivileged = 1130,
+ /// <summary>
+ /// The anonymous user is not allowed to connect
+ /// </summary>
AnonymousUser = 1131,
+ /// <summary>
+ /// The given password is not allowed
+ /// </summary>
PasswordNotAllowed = 1132,
+ /// <summary>
+ /// The given password does not match
+ /// </summary>
PasswordNoMatch = 1133,
/* ER_UPDATE_INFO 1134
ER_CANT_CREATE_THREAD 1135
@@ -227,6 +254,10 @@
ER_TOO_MANY_DELAYED_THREADS 1151
ER_ABORTING_CONNECTION 1152
*/
+ /// <summary>
+ /// An attempt was made to send or receive a packet larger than
+ /// max_allowed_packet_size
+ /// </summary>
PacketTooLarge = 1153
/*
ER_NET_READ_ERROR_FROM_PIPE 1154
Modified: branches/1.0/mysqlclient/Types/MySqlDateTime.cs
===================================================================
--- branches/1.0/mysqlclient/Types/MySqlDateTime.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/Types/MySqlDateTime.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -30,40 +30,62 @@
/// </summary>
public class MySqlDateTime : MySqlValue, IConvertible, IComparable
{
- private int year, month, day, hour, minute, second, milli;
- private static string fullPattern;
- private static string shortPattern;
+ private int year, month, day, hour, minute, second, milli;
+ private static string fullPattern;
+ private static string shortPattern;
- public MySqlDateTime(int year, int month, int day, int hour, int minute, int second)
- : this(year, month, day, hour, minute, second, MySqlDbType.Datetime)
- {
- }
+ /// <summary>
+ /// Constructor for MySqlDateTime
+ /// </summary>
+ /// <param name="year"></param>
+ /// <param name="month"></param>
+ /// <param name="day"></param>
+ /// <param name="hour"></param>
+ /// <param name="minute"></param>
+ /// <param name="second"></param>
+ public MySqlDateTime(int year, int month, int day, int hour, int minute, int second)
+ : this(year, month, day, hour, minute, second, MySqlDbType.Datetime)
+ {
+ }
- public MySqlDateTime(DateTime dt)
- : this(dt, MySqlDbType.Datetime)
- {
- }
+ /// <summary>
+ /// Constructor for MySqlDateTime
+ /// </summary>
+ /// <param name="dt"></param>
+ public MySqlDateTime(DateTime dt)
+ : this(dt, MySqlDbType.Datetime)
+ {
+ }
- public MySqlDateTime(MySqlDateTime mdt)
- {
- year = mdt.Year;
- month = mdt.Month;
- day = mdt.Day;
- hour = mdt.Hour;
- minute = mdt.Minute;
- second = mdt.Second;
- mySqlDbType = MySqlDbType.Datetime;
- isNull = false;
- }
+ /// <summary>
+ /// Constructor for MySqlDateTime
+ /// </summary>
+ /// <param name="mdt"></param>
+ public MySqlDateTime(MySqlDateTime mdt)
+ {
+ year = mdt.Year;
+ month = mdt.Month;
+ day = mdt.Day;
+ hour = mdt.Hour;
+ minute = mdt.Minute;
+ second = mdt.Second;
+ mySqlDbType = MySqlDbType.Datetime;
+ isNull = false;
+ }
- public MySqlDateTime(string s)
- : this(MySqlDateTime.Parse(s))
- {
- }
+ /// <summary>
+ /// Constructor for MySqlDateTime
+ /// </summary>
+ /// <param name="s"></param>
+ public MySqlDateTime(string s)
+ : this(MySqlDateTime.Parse(s))
+ {
+ }
- internal MySqlDateTime(int year, int month, int day, int hour, int minute,
- int second, MySqlDbType type) : this(type)
+ internal MySqlDateTime(int year, int month, int day, int hour, int minute,
+ int second, MySqlDbType type)
+ : this(type)
{
this.year = year;
this.month = month;
@@ -74,22 +96,23 @@
// we construct a date that is guaranteed not have zeros in the date part
// we do this for comparison
-// DateTime d = DateTime.MinValue;
-// d = d.AddYears(year+1).AddMonths(month+1).AddDays(day+1).AddHours(hour);
-// d = d.AddMinutes(minute).AddSeconds(second);
-// comparingDate = d;
+ // DateTime d = DateTime.MinValue;
+ // d = d.AddYears(year+1).AddMonths(month+1).AddDays(day+1).AddHours(hour);
+ // d = d.AddMinutes(minute).AddSeconds(second);
+ // comparingDate = d;
if (fullPattern == null)
ComposePatterns();
}
- internal MySqlDateTime(MySqlDbType type)
+ internal MySqlDateTime(MySqlDbType type)
{
mySqlDbType = type;
objectValue = this;
}
- internal MySqlDateTime(DateTime val, MySqlDbType type) : this(type)
+ internal MySqlDateTime(DateTime val, MySqlDbType type)
+ : this(type)
{
year = val.Year;
month = val.Month;
@@ -97,7 +120,7 @@
hour = val.Hour;
minute = val.Minute;
second = val.Second;
- milli = val.Millisecond;
+ milli = val.Millisecond;
}
#region Properties
@@ -105,132 +128,135 @@
/// <summary>
/// Indicates if this object contains a value that can be represented as a DateTime
/// </summary>
- public bool IsValidDateTime
+ public bool IsValidDateTime
{
- get
+ get
{
return year != 0 && month != 0 && day != 0;
}
}
/// <summary>Returns the year portion of this datetime</summary>
- public int Year
+ public int Year
{
get { return year; }
set { year = value; }
}
/// <summary>Returns the month portion of this datetime</summary>
- public int Month
+ public int Month
{
get { return month; }
set { month = value; }
}
/// <summary>Returns the day portion of this datetime</summary>
- public int Day
+ public int Day
{
get { return day; }
set { day = value; }
}
/// <summary>Returns the hour portion of this datetime</summary>
- public int Hour
+ public int Hour
{
get { return hour; }
set { hour = value; }
}
/// <summary>Returns the minute portion of this datetime</summary>
- public int Minute
+ public int Minute
{
get { return minute; }
set { minute = value; }
}
/// <summary>Returns the second portion of this datetime</summary>
- public int Second
+ public int Second
{
get { return second; }
set { second = value; }
}
- public int Millisecond
- {
- get { return milli; }
- set { milli = value; }
- }
+ /// <summary>
+ /// Returns the millisecond portion of this datetime
+ /// </summary>
+ public int Millisecond
+ {
+ get { return milli; }
+ set { milli = value; }
+ }
#endregion
- private void SerializeText(PacketWriter writer, MySqlDateTime value)
+ private void SerializeText(PacketWriter writer, MySqlDateTime value)
{
string val = String.Empty;
- if (mySqlDbType == MySqlDbType.Timestamp && !writer.Version.isAtLeast(4,1,0))
+ if (mySqlDbType == MySqlDbType.Timestamp && !writer.Version.isAtLeast(4, 1, 0))
val = String.Format("{0:0000}{1:00}{2:00}{3:00}{4:00}{5:00}",
- value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second );
- else
+ value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second);
+ else
{
- val = String.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}", value.Year, value.Month,
- value.Day, value.Hour, value.Minute, value.Second );
+ val = String.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}", value.Year, value.Month,
+ value.Day, value.Hour, value.Minute, value.Second);
}
- writer.WriteStringNoNull( "'" + val + "'" );
+ writer.WriteStringNoNull("'" + val + "'");
}
internal override void Serialize(PacketWriter writer, bool binary, object value, int length)
{
- MySqlDateTime dtValue;
+ MySqlDateTime dtValue;
- if (value is DateTime)
- dtValue = new MySqlDateTime((DateTime)value, MySqlDbType);
- else if (value is string)
- dtValue = new MySqlDateTime(DateTime.Parse((string)value,
- System.Globalization.CultureInfo.CurrentCulture), MySqlDbType);
- else if (value is MySqlDateTime)
- dtValue = (MySqlDateTime)value;
- else
+ if (value is DateTime)
+ dtValue = new MySqlDateTime((DateTime)value, MySqlDbType);
+ else if (value is string)
+ dtValue = new MySqlDateTime(DateTime.Parse((string)value,
+ System.Globalization.CultureInfo.CurrentCulture), MySqlDbType);
+ else if (value is MySqlDateTime)
+ dtValue = (MySqlDateTime)value;
+ else
throw new MySqlException("Unable to serialize date/time value.");
- if (! binary)
+ if (!binary)
{
SerializeText(writer, dtValue);
return;
}
if (mySqlDbType == MySqlDbType.Timestamp)
- writer.WriteByte( 11 );
+ writer.WriteByte(11);
else
- writer.WriteByte( 7 );
+ writer.WriteByte(7);
writer.WriteInteger(dtValue.Year, 2);
writer.WriteByte((byte)dtValue.Month);
writer.WriteByte((byte)dtValue.Day);
- if (mySqlDbType == MySqlDbType.Date)
+ if (mySqlDbType == MySqlDbType.Date)
{
writer.WriteByte(0);
writer.WriteByte(0);
writer.WriteByte(0);
}
- else
+ else
{
writer.WriteByte((byte)dtValue.Hour);
writer.WriteByte((byte)dtValue.Minute);
writer.WriteByte((byte)dtValue.Second);
}
-
+
if (mySqlDbType == MySqlDbType.Timestamp)
writer.WriteInteger(dtValue.Millisecond, 4);
}
- internal override DbType DbType
+ internal override DbType DbType
{
- get
- {
- switch (mySqlDbType)
+ get
+ {
+ switch (mySqlDbType)
{
- case MySqlDbType.Date:
+ case MySqlDbType.Date:
case MySqlDbType.Newdate:
return DbType.Date;
}
@@ -240,7 +266,7 @@
internal override string GetMySqlTypeName()
{
- switch (mySqlDbType)
+ switch (mySqlDbType)
{
case MySqlDbType.Date: return "DATE";
case MySqlDbType.Newdate: return "NEWDATE";
@@ -252,13 +278,13 @@
/// <summary>Returns this value as a DateTime</summary>
public DateTime GetDateTime()
{
- if (! IsValidDateTime)
- throw new MySqlConversionException("Unable to convert MySQL date/time value to System.DateTime");
+ if (!IsValidDateTime)
+ throw new MySqlConversionException("Unable to convert MySQL date/time value to System.DateTime");
- return new DateTime( year, month, day, hour, minute, second );
+ return new DateTime(year, month, day, hour, minute, second);
}
- private MySqlDateTime Parse40Timestamp( string s )
+ private MySqlDateTime Parse40Timestamp(string s)
{
int pos = 0;
year = month = day = 1;
@@ -269,7 +295,7 @@
year = int.Parse(s.Substring(pos, 4));
pos += 4;
}
- else
+ else
{
year = int.Parse(s.Substring(pos, 2));
pos += 2;
@@ -292,42 +318,42 @@
if (s.Length > 8)
{
hour = int.Parse(s.Substring(pos, 2));
- minute = int.Parse(s.Substring(pos+2, 2));
+ minute = int.Parse(s.Substring(pos + 2, 2));
pos += 4;
}
if (s.Length > 10)
second = int.Parse(s.Substring(pos, 2));
- return new MySqlDateTime(year, month, day, hour, minute,
- second, mySqlDbType );
+ return new MySqlDateTime(year, month, day, hour, minute,
+ second, mySqlDbType);
}
- internal static MySqlDateTime Parse(string s)
- {
- MySqlDateTime dt = new MySqlDateTime(MySqlDbType.Datetime);
- return dt.ParseMySql(s, true);
- }
+ internal static MySqlDateTime Parse(string s)
+ {
+ MySqlDateTime dt = new MySqlDateTime(MySqlDbType.Datetime);
+ return dt.ParseMySql(s, true);
+ }
- internal MySqlDateTime ParseMySql(string s, bool is41)
+ internal MySqlDateTime ParseMySql(string s, bool is41)
{
- if (mySqlDbType == MySqlDbType.Timestamp && ! is41)
+ if (mySqlDbType == MySqlDbType.Timestamp && !is41)
return Parse40Timestamp(s);
- string[] parts = s.Split( '-', ' ', ':', '/' );
-
- int year = int.Parse( parts[0] );
- int month = int.Parse( parts[1] );
- int day = int.Parse( parts[2] );
+ string[] parts = s.Split('-', ' ', ':', '/');
+ int year = int.Parse(parts[0]);
+ int month = int.Parse(parts[1]);
+ int day = int.Parse(parts[2]);
+
int hour = 0, minute = 0, second = 0;
- if (parts.Length > 3)
+ if (parts.Length > 3)
{
- hour = int.Parse( parts[3] );
- minute = int.Parse( parts[4] );
- second = int.Parse( parts[5] );
+ hour = int.Parse(parts[3]);
+ minute = int.Parse(parts[4]);
+ second = int.Parse(parts[5]);
}
- return new MySqlDateTime( year, month, day, hour, minute, second, mySqlDbType );
+ return new MySqlDateTime(year, month, day, hour, minute, second, mySqlDbType);
}
internal override Type SystemType
@@ -337,115 +363,120 @@
internal override MySqlValue ReadValue(PacketReader reader, long length)
{
- if (length >= 0)
+ if (length >= 0)
{
- string value = reader.ReadString( length );
- return ParseMySql( value, reader.Version.isAtLeast(4,1,0) );
+ string value = reader.ReadString(length);
+ return ParseMySql(value, reader.Version.isAtLeast(4, 1, 0));
}
long bufLength = reader.ReadByte();
- int year = 0, month = 0, day = 0;
- int hour = 0, minute = 0, second = 0;
-
- if (bufLength >= 4)
- {
- year = reader.ReadInteger(2);
- month = reader.ReadByte();
- day = reader.ReadByte();
- }
+ int year = 0, month = 0, day = 0;
+ int hour = 0, minute = 0, second = 0;
- if (bufLength > 4)
+ if (bufLength >= 4)
{
+ year = reader.ReadInteger(2);
+ month = reader.ReadByte();
+ day = reader.ReadByte();
+ }
+
+ if (bufLength > 4)
+ {
hour = reader.ReadByte();
minute = reader.ReadByte();
second = reader.ReadByte();
}
-
+
if (bufLength > 7)
reader.ReadInteger(4);
-
- return new MySqlDateTime( year, month, day, hour, minute, second, mySqlDbType );
+
+ return new MySqlDateTime(year, month, day, hour, minute, second, mySqlDbType);
}
internal override void Skip(PacketReader reader)
{
long len = reader.ReadByte();
- reader.Skip( len );
+ reader.Skip(len);
}
/// <summary>Returns a MySQL specific string representation of this value</summary>
public override string ToString()
{
- if (this.IsValidDateTime)
+ if (this.IsValidDateTime)
{
- DateTime d = new DateTime( year, month, day, hour, minute, second );
+ DateTime d = new DateTime(year, month, day, hour, minute, second);
return (mySqlDbType == MySqlDbType.Date) ? d.ToString("d") : d.ToString();
}
if (mySqlDbType == MySqlDbType.Date)
- return String.Format( shortPattern, year, month, day);
+ return String.Format(shortPattern, year, month, day);
if (hour >= 12)
fullPattern = fullPattern.Replace("A", "P");
- return String.Format( fullPattern, year, month, day, hour, minute, second);
+ return String.Format(fullPattern, year, month, day, hour, minute, second);
}
- private void ComposePatterns()
+ private void ComposePatterns()
{
DateTime tempDT = new DateTime(1, 2, 3, 4, 5, 6);
fullPattern = tempDT.ToString();
- fullPattern = fullPattern.Replace( "0001", "{0:0000}" );
+ fullPattern = fullPattern.Replace("0001", "{0:0000}");
if (fullPattern.IndexOf("02") != -1)
- fullPattern = fullPattern.Replace( "02", "{1:00}" );
+ fullPattern = fullPattern.Replace("02", "{1:00}");
else
- fullPattern = fullPattern.Replace("2", "{1}" );
+ fullPattern = fullPattern.Replace("2", "{1}");
if (fullPattern.IndexOf("03") != -1)
- fullPattern = fullPattern.Replace( "03", "{2:00}" );
+ fullPattern = fullPattern.Replace("03", "{2:00}");
else
- fullPattern = fullPattern.Replace("3", "{2}" );
+ fullPattern = fullPattern.Replace("3", "{2}");
if (fullPattern.IndexOf("04") != -1)
- fullPattern = fullPattern.Replace( "04", "{3:00}" );
+ fullPattern = fullPattern.Replace("04", "{3:00}");
else
- fullPattern = fullPattern.Replace("4", "{3}" );
+ fullPattern = fullPattern.Replace("4", "{3}");
if (fullPattern.IndexOf("05") != -1)
- fullPattern = fullPattern.Replace( "05", "{4:00}" );
+ fullPattern = fullPattern.Replace("05", "{4:00}");
else
- fullPattern = fullPattern.Replace("5", "{4}" );
+ fullPattern = fullPattern.Replace("5", "{4}");
if (fullPattern.IndexOf("06") != -1)
- fullPattern = fullPattern.Replace( "06", "{5:00}" );
+ fullPattern = fullPattern.Replace("06", "{5:00}");
else
- fullPattern = fullPattern.Replace("6", "{5}" );
+ fullPattern = fullPattern.Replace("6", "{5}");
shortPattern = tempDT.ToString("d");
- shortPattern = shortPattern.Replace( "0001", "{0:0000}" );
+ shortPattern = shortPattern.Replace("0001", "{0:0000}");
if (shortPattern.IndexOf("02") != -1)
- shortPattern = shortPattern.Replace( "02", "{1:00}" );
+ shortPattern = shortPattern.Replace("02", "{1:00}");
else
- shortPattern = shortPattern.Replace("2", "{1}" );
+ shortPattern = shortPattern.Replace("2", "{1}");
if (shortPattern.IndexOf("03") != -1)
- shortPattern = shortPattern.Replace( "03", "{2:00}" );
+ shortPattern = shortPattern.Replace("03", "{2:00}");
else
- shortPattern = shortPattern.Replace("3", "{2}" );
+ shortPattern = shortPattern.Replace("3", "{2}");
}
/// <summary></summary>
/// <param name="val"></param>
/// <returns></returns>
- public static explicit operator DateTime( MySqlDateTime val )
+ public static explicit operator DateTime(MySqlDateTime val)
{
- if (! val.IsValidDateTime) return DateTime.MinValue;
+ if (!val.IsValidDateTime) return DateTime.MinValue;
return val.GetDateTime();
}
- public static implicit operator MySqlDateTime(DateTime v)
- {
- MySqlDateTime dt = new MySqlDateTime(v, MySqlDbType.Datetime);
- return dt;
- }
+ /// <summary>
+ /// Implicit conversion operator for MySqlDateTime
+ /// </summary>
+ /// <param name="v"></param>
+ /// <returns></returns>
+ public static implicit operator MySqlDateTime(DateTime v)
+ {
+ MySqlDateTime dt = new MySqlDateTime(v, MySqlDbType.Datetime);
+ return dt;
+ }
#region IConvertible Members
- ulong IConvertible.ToUInt64 (IFormatProvider provider)
+ ulong IConvertible.ToUInt64(IFormatProvider provider)
{
return 0;
}
@@ -513,7 +544,7 @@
System.TypeCode IConvertible.GetTypeCode()
{
- return new System.TypeCode ();
+ return new System.TypeCode();
}
decimal IConvertible.ToDecimal(IFormatProvider provider)
Modified: branches/1.0/mysqlclient/common/SharedMemoryStream.cs
===================================================================
--- branches/1.0/mysqlclient/common/SharedMemoryStream.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/common/SharedMemoryStream.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -30,23 +30,23 @@
/// </summary>
internal class SharedMemoryStream : Stream
{
- private string memoryName;
- private AutoResetEvent serverRead;
- private AutoResetEvent serverWrote;
- private AutoResetEvent clientRead;
- private AutoResetEvent clientWrote;
- private IntPtr dataMap;
- private IntPtr dataView;
- private int bytesLeft;
- private int position;
- private int connectNumber;
+ private string memoryName;
+ private AutoResetEvent serverRead;
+ private AutoResetEvent serverWrote;
+ private AutoResetEvent clientRead;
+ private AutoResetEvent clientWrote;
+ private IntPtr dataMap;
+ private IntPtr dataView;
+ private int bytesLeft;
+ private int position;
+ private int connectNumber;
- private uint SYNCHRONIZE = 0x00100000;
- private uint READ_CONTROL = 0x00020000;
- private uint EVENT_MODIFY_STATE = 0x2;
- private uint EVENT_ALL_ACCESS = 0x001F0003;
- private uint FILE_MAP_WRITE = 0x2;
- private int BUFFERLENGTH = 16004;
+ private const uint SYNCHRONIZE = 0x00100000;
+ private const uint READ_CONTROL = 0x00020000;
+ private const uint EVENT_MODIFY_STATE = 0x2;
+ private const uint EVENT_ALL_ACCESS = 0x001F0003;
+ private const uint FILE_MAP_WRITE = 0x2;
+ private const int BUFFERLENGTH = 16004;
public SharedMemoryStream(string memName)
{
@@ -59,21 +59,21 @@
SetupEvents();
}
- public override void Close()
+ public override void Close()
{
- UnmapViewOfFile( dataView );
- CloseHandle( dataMap );
+ UnmapViewOfFile(dataView);
+ CloseHandle(dataMap);
}
private void GetConnectNumber(int timeOut)
{
AutoResetEvent connectRequest = new AutoResetEvent(false);
- connectRequest.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
- false, memoryName + "_" + "CONNECT_REQUEST");
+ connectRequest.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
+ false, memoryName + "_" + "CONNECT_REQUEST");
AutoResetEvent connectAnswer = new AutoResetEvent(false);
- connectAnswer.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
- false, memoryName + "_" + "CONNECT_ANSWER");
+ connectAnswer.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
+ false, memoryName + "_" + "CONNECT_ANSWER");
IntPtr connectFileMap = OpenFileMapping(FILE_MAP_WRITE, false,
memoryName + "_" + "CONNECT_DATA");
@@ -81,10 +81,10 @@
0, 0, (UIntPtr)4);
// now start the connection
- if (! connectRequest.Set())
+ if (!connectRequest.Set())
throw new MySqlException("Failed to open shared memory connection ");
- connectAnswer.WaitOne(timeOut*1000, false);
+ connectAnswer.WaitOne(timeOut * 1000, false);
connectNumber = Marshal.ReadInt32(connectView);
}
@@ -92,25 +92,25 @@
private void SetupEvents()
{
string dataMemoryName = memoryName + "_" + connectNumber;
- dataMap = OpenFileMapping( FILE_MAP_WRITE, false,
- dataMemoryName + "_DATA" );
- dataView = MapViewOfFile( dataMap, FILE_MAP_WRITE, 0, 0, (UIntPtr)(uint)BUFFERLENGTH );
+ dataMap = OpenFileMapping(FILE_MAP_WRITE, false,
+ dataMemoryName + "_DATA");
+ dataView = MapViewOfFile(dataMap, FILE_MAP_WRITE, 0, 0, (UIntPtr)(uint)BUFFERLENGTH);
serverWrote = new AutoResetEvent(false);
- serverWrote.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
- false, dataMemoryName + "_SERVER_WROTE");
+ serverWrote.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
+ false, dataMemoryName + "_SERVER_WROTE");
serverRead = new AutoResetEvent(false);
- serverRead.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
- false, dataMemoryName + "_SERVER_READ");
+ serverRead.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
+ false, dataMemoryName + "_SERVER_READ");
clientWrote = new AutoResetEvent(false);
- clientWrote.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
- false, dataMemoryName + "_CLIENT_WROTE");
+ clientWrote.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
+ false, dataMemoryName + "_CLIENT_WROTE");
clientRead = new AutoResetEvent(false);
- clientRead.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
- false, dataMemoryName + "_CLIENT_READ");
+ clientRead.Handle = OpenEvent(SYNCHRONIZE | EVENT_MODIFY_STATE,
+ false, dataMemoryName + "_CLIENT_READ");
// tell the server we are ready
serverRead.Set();
@@ -119,7 +119,7 @@
#region Properties
public override bool CanRead
{
- get { return true; }
+ get { return true; }
}
public override bool CanSeek
@@ -140,25 +140,25 @@
public override long Position
{
get { throw new NotSupportedException("SharedMemoryStream does not support seeking - postition"); }
- set {}
+ set { }
}
#endregion
public override void Flush()
{
- FlushViewOfFile( dataView, 0 );
+ FlushViewOfFile(dataView, 0);
}
- public bool IsClosed()
+ public bool IsClosed()
{
- try
+ try
{
- dataView = MapViewOfFile( dataMap, FILE_MAP_WRITE, 0, 0, (UIntPtr)(uint)BUFFERLENGTH );
+ dataView = MapViewOfFile(dataMap, FILE_MAP_WRITE, 0, 0, (UIntPtr)(uint)BUFFERLENGTH);
if (dataView == IntPtr.Zero) return true;
return false;
}
- catch (Exception)
+ catch (Exception)
{
return true;
}
@@ -168,24 +168,24 @@
{
while (bytesLeft == 0)
{
- while (! serverWrote.WaitOne(500, false))
+ while (!serverWrote.WaitOne(500, false))
{
if (IsClosed()) return 0;
}
- bytesLeft = Marshal.ReadInt32( dataView );
+ bytesLeft = Marshal.ReadInt32(dataView);
position = 4;
}
- int len = Math.Min( count, bytesLeft );
+ int len = Math.Min(count, bytesLeft);
long baseMem = dataView.ToInt64() + position;
- for (int i=0; i < len; i++, position++)
- buffer[offset+i] = Marshal.ReadByte( (IntPtr)( baseMem + i ) );
+ for (int i = 0; i < len; i++, position++)
+ buffer[offset + i] = Marshal.ReadByte((IntPtr)(baseMem + i));
bytesLeft -= len;
- if ( bytesLeft == 0)
+ if (bytesLeft == 0)
clientRead.Set();
return len;
@@ -203,17 +203,17 @@
while (leftToDo > 0)
{
- if (! serverRead.WaitOne())
+ if (!serverRead.WaitOne())
throw new MySqlException("Writing to shared memory failed");
- int bytesToDo = Math.Min( leftToDo, BUFFERLENGTH );
+ int bytesToDo = Math.Min(leftToDo, BUFFERLENGTH);
long baseMem = dataView.ToInt64() + 4;
- Marshal.WriteInt32( dataView, bytesToDo );
- for (int i=0; i < bytesToDo; i++, buffPos++)
- Marshal.WriteByte( (IntPtr)(baseMem + i), buffer[ buffPos ] );
+ Marshal.WriteInt32(dataView, bytesToDo);
+ for (int i = 0; i < bytesToDo; i++, buffPos++)
+ Marshal.WriteByte((IntPtr)(baseMem + i), buffer[buffPos]);
leftToDo -= bytesToDo;
- if (! clientWrote.Set())
+ if (!clientWrote.Set())
throw new MySqlException("Writing to shared memory failed");
}
}
@@ -225,13 +225,13 @@
-#region Imports
+ #region Imports
[DllImport("kernel32.dll")]
static extern IntPtr OpenEvent(uint dwDesiredAccess, bool bInheritHandle,
string lpName);
-// [DllImport("kernel32.dll")]
-// static extern bool SetEvent(IntPtr hEvent);
+ // [DllImport("kernel32.dll")]
+ // static extern bool SetEvent(IntPtr hEvent);
[DllImport("kernel32.dll")]
static extern IntPtr OpenFileMapping(uint dwDesiredAccess, bool bInheritHandle,
@@ -245,13 +245,13 @@
[DllImport("kernel32.dll")]
static extern bool UnmapViewOfFile(IntPtr lpBaseAddress);
- [DllImport("kernel32.dll", SetLastError=true)]
+ [DllImport("kernel32.dll", SetLastError = true)]
static extern int CloseHandle(IntPtr hObject);
- [DllImport("kernel32.dll", SetLastError=true)]
- static extern int FlushViewOfFile( IntPtr address, uint numBytes );
+ [DllImport("kernel32.dll", SetLastError = true)]
+ static extern int FlushViewOfFile(IntPtr address, uint numBytes);
-#endregion
+ #endregion
Modified: branches/1.0/mysqlclient/common/SocketStream.cs
===================================================================
--- branches/1.0/mysqlclient/common/SocketStream.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/common/SocketStream.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -163,7 +163,6 @@
public bool Connect(EndPoint remoteEP, int timeout)
{
- int err;
// set the socket to non blocking
socket.Blocking = false;
Modified: branches/1.0/mysqlclient/dataadapter.cs
===================================================================
--- branches/1.0/mysqlclient/dataadapter.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/dataadapter.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -311,10 +311,10 @@
/// <summary>
/// Initializes a new instance of the MySqlRowUpdatingEventArgs class.
/// </summary>
- /// <param name="row">The <see cref="DataRow"/> to <see cref="DbDataAdapter.Update"/>.</param>
- /// <param name="command">The <see cref="IDbCommand"/> to execute during <see cref="DbDataAdapter.Update"/>.</param>
+ /// <param name="row">The <see cref="DataRow"/> to <see cref="DbDataAdapter.Update(DataSet)"/>.</param>
+ /// <param name="command">The <see cref="IDbCommand"/> to execute during <see cref="DbDataAdapter.Update(DataSet)"/>.</param>
/// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
- /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
+ /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update(DataSet)"/>.</param>
public MySqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
: base(row, command, statementType, tableMapping)
{
@@ -338,10 +338,10 @@
/// <summary>
/// Initializes a new instance of the MySqlRowUpdatedEventArgs class.
/// </summary>
- /// <param name="row">The <see cref="DataRow"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
- /// <param name="command">The <see cref="IDbCommand"/> executed when <see cref="DbDataAdapter.Update"/> is called.</param>
+ /// <param name="row">The <see cref="DataRow"/> sent through an <see cref="DbDataAdapter.Update(DataSet)"/>.</param>
+ /// <param name="command">The <see cref="IDbCommand"/> executed when <see cref="DbDataAdapter.Update(DataSet)"/> is called.</param>
/// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
- /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
+ /// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update(DataSet)"/>.</param>
public MySqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
: base(row, command, statementType, tableMapping)
{
Modified: branches/1.0/mysqlclient/docs/MySqlCommand.xml
===================================================================
--- branches/1.0/mysqlclient/docs/MySqlCommand.xml 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/docs/MySqlCommand.xml 2006-10-18 21:25:06 UTC (rev 415)
@@ -1,789 +1,927 @@
<docs>
-<ClassSummary>
- <summary>Represents a SQL statement to execute against a MySQL database. This class cannot be inherited.</summary>
- <remarks>
- <B>MySqlCommand</B> features the following methods for executing commands at a MySQL database:
- <list type="table">
- <listheader><term>Item</term><term>Description</term></listheader>
- <item>
- <term><a href="MySql.Data.MySqlClient.MySqlCommand.ExecuteReader_overloads.html">ExecuteReader</a></term>
- <description>Executes commands that return rows.</description>
- </item>
- <item>
- <term><a href="MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery.html">ExecuteNonQuery</a></term>
- <description>Executes commands such as SQL INSERT, DELETE, and UPDATE statements.</description>
- </item>
- <item>
- <term><a href="MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar.html">ExecuteScalar</a></term>
- <description>Retrieves a single value (for example, an aggregate value) from a database.</description>
- </item>
- </list>
+ <ClassSummary>
+ <summary>Represents a SQL statement to execute against a MySQL database. This class cannot be inherited.</summary>
+ <remarks>
+ <B>MySqlCommand</B> features the following methods for executing commands at a MySQL database:
+ <list type="table">
+ <listheader>
+ <term>Item</term>
+ <term>Description</term>
+ </listheader>
+ <item>
+ <term>
+ <a href="MySql.Data.MySqlClient.MySqlCommand.ExecuteReader_overloads.html">ExecuteReader</a>
+ </term>
+ <description>Executes commands that return rows.</description>
+ </item>
+ <item>
+ <term>
+ <a href="MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery.html">ExecuteNonQuery</a>
+ </term>
+ <description>Executes commands such as SQL INSERT, DELETE, and UPDATE statements.</description>
+ </item>
+ <item>
+ <term>
+ <a href="MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar.html">ExecuteScalar</a>
+ </term>
+ <description>Retrieves a single value (for example, an aggregate value) from a database.</description>
+ </item>
+ </list>
- You can reset the <B>CommandText</B> property and reuse the <B>MySqlCommand</B>
- object. However, you must close the <A
- href="MySql.Data.MySqlClient.MySqlDataReader.html">MySqlDataReader</A>
- before you can execute a new or previous command.
+ You can reset the <B>CommandText</B> property and reuse the <B>MySqlCommand</B>
+ object. However, you must close the <A
+ href="MySql.Data.MySqlClient.MySqlDataReader.html">MySqlDataReader</A>
+ before you can execute a new or previous command.
- If a <A href="MySql.Data.MySqlClient.MySqlException.html">MySqlException</A> is
- generated by the method executing a <B>MySqlCommand</B>, the <A
- href="MySql.Data.MySqlClient.MySqlConnection.html">MySqlConnection</A>
- remains open. It is the responsibility of the programmer to close the connection.
-
- <note>
- Prior versions of the provider used the '@' symbol to mark parameters in SQL. This is incompatible
- with MySQL user variables, so the provider now uses the '?' symbol to locate parameters in SQL. To
- support older code, you can set 'old syntax=yes' on your connection string. If you do this, please
- be aware that an exception will not be throw if you fail to define a parameter that you intended to
- use in your SQL.
- </note>
- </remarks>
+ If a <A href="MySql.Data.MySqlClient.MySqlException.html">MySqlException</A> is
+ generated by the method executing a <B>MySqlCommand</B>, the <A
+ href="MySql.Data.MySqlClient.MySqlConnection.html">MySqlConnection</A>
+ remains open. It is the responsibility of the programmer to close the connection.
- <example>
- The following example creates a <A href="frlrfsystemdatasqlclientsqlcommandclasstopic.htm">MySqlCommand</A> and
- a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the <A
- href="frlrfsystemdatasqlclientsqlcommandclassconnectiontopic.htm">Connection</A>
- for the <B>MySqlCommand</B>. The example then calls <A
- href="frlrfsystemdatasqlclientsqlcommandclassexecutenonquerytopic.htm">ExecuteNonQuery</A>,
- and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
- passed a connection string and a query string that is a SQL INSERT
- statement.
- <code lang="Visual Basic">
- Public Sub InsertRow(myConnectionString As String)
- " If the connection string is null, use a default.
- If myConnectionString = "" Then
- myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"
- End If
- Dim myConnection As New MySqlConnection(myConnectionString)
- Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"
- Dim myCommand As New MySqlCommand(myInsertQuery)
- myCommand.Connection = myConnection
- myConnection.Open()
- myCommand.ExecuteNonQuery()
- myCommand.Connection.Close()
- End Sub
- </code>
- <code lang="C#">
- public void InsertRow(string myConnectionString)
- {
- // If the connection string is null, use a default.
- if(myConnectionString == "")
- {
- myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";
- }
- MySqlConnection myConnection = new MySqlConnection(myConnectionString);
- string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";
- MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
- myCommand.Connection = myConnection;
- myConnection.Open();
- myCommand.ExecuteNonQuery();
- myCommand.Connection.Close();
- }
- </code>
- </example>
-</ClassSummary>
+ <note>
+ Prior versions of the provider used the '@' symbol to mark parameters in SQL. This is incompatible
+ with MySQL user variables, so the provider now uses the '?' symbol to locate parameters in SQL. To
+ support older code, you can set 'old syntax=yes' on your connection string. If you do this, please
+ be aware that an exception will not be throw if you fail to define a parameter that you intended to
+ use in your SQL.
+ </note>
+ </remarks>
+ <example>
+ The following example creates a <A href="frlrfsystemdatasqlclientsqlcommandclasstopic.htm">MySqlCommand</A> and
+ a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the <A
+ href="frlrfsystemdatasqlclientsqlcommandclassconnectiontopic.htm">Connection</A>
+ for the <B>MySqlCommand</B>. The example then calls <A
+ href="frlrfsystemdatasqlclientsqlcommandclassexecutenonquerytopic.htm">ExecuteNonQuery</A>,
+ and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
+ passed a connection string and a query string that is a SQL INSERT
+ statement.
+ <code lang="Visual Basic">
+ Public Sub InsertRow(myConnectionString As String)
+ " If the connection string is null, use a default.
+ If myConnectionString = "" Then
+ myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"
+ End If
+ Dim myConnection As New MySqlConnection(myConnectionString)
+ Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"
+ Dim myCommand As New MySqlCommand(myInsertQuery)
+ myCommand.Connection = myConnection
+ myConnection.Open()
+ myCommand.ExecuteNonQuery()
+ myCommand.Connection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void InsertRow(string myConnectionString)
+ {
+ // If the connection string is null, use a default.
+ if(myConnectionString == "")
+ {
+ myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";
+ }
+ MySqlConnection myConnection = new MySqlConnection(myConnectionString);
+ string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";
+ MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
+ myCommand.Connection = myConnection;
+ myConnection.Open();
+ myCommand.ExecuteNonQuery();
+ myCommand.Connection.Close();
+ }
+ </code>
+ </example>
+ </ClassSummary>
-<ctor1>
- <overloads>
- <summary>
- Initializes a new instance of the MySqlCommand class.
- </summary>
- <example>
- The following example creates a MySqlCommand and sets some of its properties.
- <para></para>
- <note>This example shows how to use one of the overloaded
- versions of the MySqlCommand constructor. For other examples that might be available,
- see the individual overload topics.
- </note>
-
- <code lang="Visual Basic">
- Public Sub CreateMySqlCommand()
- Dim myConnection As New MySqlConnection _
- ("Persist Security Info=False;database=test;server=myServer")
- myConnection.Open()
- Dim myTrans As MySqlTransaction = myConnection.BeginTransaction()
- Dim mySelectQuery As String = "SELECT * FROM MyTable"
- Dim myCommand As New MySqlCommand(mySelectQuery, myConnection, myTrans)
- myCommand.CommandTimeout = 20
- End Sub
- </code>
- <code lang="C#">
- public void CreateMySqlCommand()
- {
- MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False;
- database=test;server=myServer");
- myConnection.Open();
- MySqlTransaction myTrans = myConnection.BeginTransaction();
- string mySelectQuery = "SELECT * FROM myTable";
- MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans);
- myCommand.CommandTimeout = 20;
- }
- </code>
- <code lang="C++">
- public:
- void CreateMySqlCommand()
- {
- MySqlConnection* myConnection = new MySqlConnection(S"Persist Security Info=False;
- database=test;server=myServer");
- myConnection->Open();
- MySqlTransaction* myTrans = myConnection->BeginTransaction();
- String* mySelectQuery = S"SELECT * FROM myTable";
- MySqlCommand* myCommand = new MySqlCommand(mySelectQuery, myConnection, myTrans);
- myCommand->CommandTimeout = 20;
- };
- </code>
- </example>
- </overloads>
+ <ctor1>
+ <overloads>
+ <summary>
+ Initializes a new instance of the MySqlCommand class.
+ </summary>
+ <example>
+ The following example creates a MySqlCommand and sets some of its properties.
+ <para></para>
+ <note>
+ This example shows how to use one of the overloaded
+ versions of the MySqlCommand constructor. For other examples that might be available,
+ see the individual overload topics.
+ </note>
- <summary>
- Initializes a new instance of the MySqlCommand class.
- </summary>
- <remarks>
- The base constructor initializes all fields to their default values. The
- following table shows initial property values for an instance of <see cref="MySqlCommand"/>.
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="CommandText"/></term><term>empty string ("")</term></item>
- <item><term><see cref="CommandTimeout"/></term><term>0</term></item>
- <item><term><see cref="CommandType"/></term><term>CommandType.Text</term></item>
- <item><term><see cref="Connection"/></term><term>Null</term></item>
- </list>
- <para>
- You can change the value for any of these properties through a separate call to
- the property.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlCommand"/> and
- sets some of its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim myConnection As New MySqlConnection _
+ ("Persist Security Info=False;database=test;server=myServer")
+ myConnection.Open()
+ Dim myTrans As MySqlTransaction = myConnection.BeginTransaction()
+ Dim mySelectQuery As String = "SELECT * FROM MyTable"
+ Dim myCommand As New MySqlCommand(mySelectQuery, myConnection, myTrans)
+ myCommand.CommandTimeout = 20
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False;
+ database=test;server=myServer");
+ myConnection.Open();
+ MySqlTransaction myTrans = myConnection.BeginTransaction();
+ string mySelectQuery = "SELECT * FROM myTable";
+ MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans);
+ myCommand.CommandTimeout = 20;
+ }
+ </code>
+ <code lang="C++">
+ public:
+ void CreateMySqlCommand()
+ {
+ MySqlConnection* myConnection = new MySqlConnection(S"Persist Security Info=False;
+ database=test;server=myServer");
+ myConnection->Open();
+ MySqlTransaction* myTrans = myConnection->BeginTransaction();
+ String* mySelectQuery = S"SELECT * FROM myTable";
+ MySqlCommand* myCommand = new MySqlCommand(mySelectQuery, myConnection, myTrans);
+ myCommand->CommandTimeout = 20;
+ };
+ </code>
+ </example>
+ </overloads>
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim myCommand As New MySqlCommand()
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
-{
- MySqlCommand myCommand = new MySqlCommand();
- myCommand.CommandType = CommandType.Text;
-}
-</code>
- </example>
-</ctor1>
-<ctor2>
- <summary>
- Initializes a new instance of the <see cref="MySqlCommand"/> class with the text of the query.
- </summary>
- <param name="cmdText">The text of the query.</param>
- <remarks>
- When an instance of <see cref="MySqlCommand"/> is created,
- the following read/write properties are set to initial values.
-
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="CommandText"/></term><term><i>cmdText</i></term></item>
- <item><term><see cref="CommandTimeout"/></term><term>0</term></item>
- <item><term><see cref="CommandType"/></term><term>CommandType.Text</term></item>
- <item><term><see cref="Connection"/></term><term>Null</term></item>
- </list>
- <para>
- You can change the value for any of these properties through a separate call to
- the property.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlCommand"/> and
- sets some of its properties.
+ <summary>
+ Initializes a new instance of the MySqlCommand class.
+ </summary>
+ <remarks>
+ The base constructor initializes all fields to their default values. The
+ following table shows initial property values for an instance of <see cref="MySqlCommand"/>.
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="CommandText"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandTimeout"/>
+ </term>
+ <term>0</term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandType"/>
+ </term>
+ <term>CommandType.Text</term>
+ </item>
+ <item>
+ <term>
+ <see cref="Connection"/>
+ </term>
+ <term>Null</term>
+ </item>
+ </list>
+ <para>
+ You can change the value for any of these properties through a separate call to
+ the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and
+ sets some of its properties.
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim sql as String = "SELECT * FROM mytable"
- Dim myCommand As New MySqlCommand(sql)
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
-{
- string sql = "SELECT * FROM mytable";
- MySqlCommand myCommand = new MySqlCommand(sql);
- myCommand.CommandType = CommandType.Text;
-}
-</code>
-</example>
-</ctor2>
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim myCommand As New MySqlCommand()
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ MySqlCommand myCommand = new MySqlCommand();
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
+ </ctor1>
-<ctor3>
- <summary>
- Initializes a new instance of the <see cref="MySqlCommand"/> class
- with the text of the query and a <see cref="MySqlConnection"/>.
- </summary>
- <param name="cmdText">The text of the query.</param>
- <param name="connection">A <see cref="MySqlConnection"/> that represents the
- connection to an instance of SQL Server.
- </param>
- <remarks>
- When an instance of <see cref="MySqlCommand"/> is created,
- the following read/write properties are set to initial values.
-
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="CommandText"/></term><term><i>cmdText</i></term></item>
- <item><term><see cref="CommandTimeout"/></term><term>0</term></item>
- <item><term><see cref="CommandType"/></term><term>CommandType.Text</term></item>
- <item><term><see cref="Connection"/></term><term><i>connection</i></term></item>
- </list>
- <para>
- You can change the value for any of these properties through a separate call to
- the property.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlCommand"/> and
- sets some of its properties.
+ <ctor2>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlCommand"/> class with the text of the query.
+ </summary>
+ <param name="cmdText">The text of the query.</param>
+ <remarks>
+ When an instance of <see cref="MySqlCommand"/> is created,
+ the following read/write properties are set to initial values.
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim conn as new MySqlConnection("server=myServer")
- Dim sql as String = "SELECT * FROM mytable"
- Dim myCommand As New MySqlCommand(sql, conn)
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
-{
- MySqlConnection conn = new MySqlConnection("server=myserver")
- string sql = "SELECT * FROM mytable";
- MySqlCommand myCommand = new MySqlCommand(sql, conn);
- myCommand.CommandType = CommandType.Text;
-}
-</code>
-</example>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="CommandText"/>
+ </term>
+ <term>
+ <i>cmdText</i>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandTimeout"/>
+ </term>
+ <term>0</term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandType"/>
+ </term>
+ <term>CommandType.Text</term>
+ </item>
+ <item>
+ <term>
+ <see cref="Connection"/>
+ </term>
+ <term>Null</term>
+ </item>
+ </list>
+ <para>
+ You can change the value for any of these properties through a separate call to
+ the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and
+ sets some of its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim sql as String = "SELECT * FROM mytable"
+ Dim myCommand As New MySqlCommand(sql)
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ string sql = "SELECT * FROM mytable";
+ MySqlCommand myCommand = new MySqlCommand(sql);
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
+ </ctor2>
-</ctor3>
+ <ctor3>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlCommand"/> class
+ with the text of the query and a <see cref="MySqlConnection"/>.
+ </summary>
+ <param name="cmdText">The text of the query.</param>
+ <param name="connection">
+ A <see cref="MySqlConnection"/> that represents the
+ connection to an instance of SQL Server.
+ </param>
+ <remarks>
+ When an instance of <see cref="MySqlCommand"/> is created,
+ the following read/write properties are set to initial values.
-<ctor4>
- <summary>
- Initializes a new instance of the <see cref="MySqlCommand"/> class
- with the text of the query, a <see cref="MySqlConnection"/>, and the
- <see cref="MySqlTransaction"/>.
- </summary>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="CommandText"/>
+ </term>
+ <term>
+ <i>cmdText</i>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandTimeout"/>
+ </term>
+ <term>0</term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandType"/>
+ </term>
+ <term>CommandType.Text</term>
+ </item>
+ <item>
+ <term>
+ <see cref="Connection"/>
+ </term>
+ <term>
+ <i>connection</i>
+ </term>
+ </item>
+ </list>
+ <para>
+ You can change the value for any of these properties through a separate call to
+ the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and
+ sets some of its properties.
- <param name="cmdText">The text of the query.</param>
- <param name="connection">A <see cref="MySqlConnection"/> that represents the
- connection to an instance of SQL Server.
- </param>
- <param name="transaction">The <see cref="MySqlTransaction"/> in which the <see cref="MySqlCommand"/> executes.</param>
- <remarks>
- When an instance of <see cref="MySqlCommand"/> is created,
- the following read/write properties are set to initial values.
-
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="CommandText"/></term><term><i>cmdText</i></term></item>
- <item><term><see cref="CommandTimeout"/></term><term>0</term></item>
- <item><term><see cref="CommandType"/></term><term>CommandType.Text</term></item>
- <item><term><see cref="Connection"/></term><term><i>connection</i></term></item>
- </list>
- <para>
- You can change the value for any of these properties through a separate call to
- the property.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlCommand"/> and
- sets some of its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim conn as new MySqlConnection("server=myServer")
+ Dim sql as String = "SELECT * FROM mytable"
+ Dim myCommand As New MySqlCommand(sql, conn)
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ MySqlConnection conn = new MySqlConnection("server=myserver")
+ string sql = "SELECT * FROM mytable";
+ MySqlCommand myCommand = new MySqlCommand(sql, conn);
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim conn as new MySqlConnection("server=myServer")
- conn.Open();
- Dim txn as MySqlTransaction = conn.BeginTransaction()
- Dim sql as String = "SELECT * FROM mytable"
- Dim myCommand As New MySqlCommand(sql, conn, txn)
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
-{
- MySqlConnection conn = new MySqlConnection("server=myserver")
- conn.Open();
- MySqlTransaction txn = conn.BeginTransaction();
- string sql = "SELECT * FROM mytable";
- MySqlCommand myCommand = new MySqlCommand(sql, conn, txn);
- myCommand.CommandType = CommandType.Text;
-}
-</code>
-</example>
-</ctor4>
+ </ctor3>
+ <ctor4>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlCommand"/> class
+ with the text of the query, a <see cref="MySqlConnection"/>, and the
+ <see cref="MySqlTransaction"/>.
+ </summary>
+ <param name="cmdText">The text of the query.</param>
+ <param name="connection">
+ A <see cref="MySqlConnection"/> that represents the
+ connection to an instance of SQL Server.
+ </param>
+ <param name="transaction">
+ The <see cref="MySqlTransaction"/> in which the <see cref="MySqlCommand"/> executes.
+ </param>
+ <remarks>
+ When an instance of <see cref="MySqlCommand"/> is created,
+ the following read/write properties are set to initial values.
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="CommandText"/>
+ </term>
+ <term>
+ <i>cmdText</i>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandTimeout"/>
+ </term>
+ <term>0</term>
+ </item>
+ <item>
+ <term>
+ <see cref="CommandType"/>
+ </term>
+ <term>CommandType.Text</term>
+ </item>
+ <item>
+ <term>
+ <see cref="Connection"/>
+ </term>
+ <term>
+ <i>connection</i>
+ </term>
+ </item>
+ </list>
+ <para>
+ You can change the value for any of these properties through a separate call to
+ the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and
+ sets some of its properties.
-<ExecuteNonQuery>
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim conn as new MySqlConnection("server=myServer")
+ conn.Open();
+ Dim txn as MySqlTransaction = conn.BeginTransaction()
+ Dim sql as String = "SELECT * FROM mytable"
+ Dim myCommand As New MySqlCommand(sql, conn, txn)
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ MySqlConnection conn = new MySqlConnection("server=myserver")
+ conn.Open();
+ MySqlTransaction txn = conn.BeginTransaction();
+ string sql = "SELECT * FROM mytable";
+ MySqlCommand myCommand = new MySqlCommand(sql, conn, txn);
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
- <summary>
- Executes a SQL statement against the connection and returns the number of rows affected.
- </summary>
- <returns>Number of rows affected</returns>
- <remarks>
- You can use ExecuteNonQuery to perform any type of database operation,
- however any resultsets returned will not be available. Any output parameters
- used in calling a stored procedure will be populated with data and can be
- retrieved after execution is complete.
- For UPDATE, INSERT, and DELETE statements, the return value is the number
- of rows affected by the command. For all other types of statements, the return
- value is -1.
- </remarks>
- <example>
- The following example creates a MySqlCommand and then
- executes it using ExecuteNonQuery. The example is passed a string that is a
- SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to
- connect to the data source.
- <code lang="Visual Basic">
- Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As MySqlConnection)
- Dim myCommand As New MySqlCommand(myExecuteQuery, myConnection)
- myCommand.Connection.Open()
- myCommand.ExecuteNonQuery()
- myConnection.Close()
- End Sub
- </code>
- <code lang="C#">
- public void CreateMySqlCommand(string myExecuteQuery, MySqlConnection myConnection)
- {
- MySqlCommand myCommand = new MySqlCommand(myExecuteQuery, myConnection);
- myCommand.Connection.Open();
- myCommand.ExecuteNonQuery();
- myConnection.Close();
- }
- </code>
- </example>
-</ExecuteNonQuery>
+ </ctor4>
-<ExecuteReader1>
- <summary>
- Sends the <see cref="CommandText"/> to the <see cref="MySqlConnection">Connection</see>,
- and builds a <see cref="MySqlDataReader"/> using one of the <see cref="CommandBehavior"/> values.
- </summary>
- <param name="behavior">One of the <see cref="CommandBehavior"/> values.</param>
- <remarks>
- <para>
- When the <see cref="CommandType"/> property is set to <B>StoredProcedure</B>,
- the <see cref="CommandText"/> property should be set to the name of the stored
- procedure. The command executes this stored procedure when you call
- <B>ExecuteReader</B>.
- </para>
- <para>
- The <see cref="MySqlDataReader"/> supports a special mode that enables large binary
- values to be read efficiently. For more information, see the <B>SequentialAccess</B>
- setting for <see cref="CommandBehavior"/>.
- </para>
- <para>
- While the <see cref="MySqlDataReader"/> is in use, the associated
- <see cref="MySqlConnection"/> is busy serving the <B>MySqlDataReader</B>.
- While in this state, no other operations can be performed on the
- <B>MySqlConnection</B> other than closing it. This is the case until the
- <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
- If the <B>MySqlDataReader</B> is created with <B>CommandBehavior</B> set to
- <B>CloseConnection</B>, closing the <B>MySqlDataReader</B> closes the connection
- automatically.
- </para>
- <note>
- When calling ExecuteReader with the SingleRow behavior, you should be aware that using a <i>limit</i>
- clause in your SQL will cause all rows (up to the limit given) to be retrieved by the client. The
- <see cref="MySqlDataReader.Read"/> method will still return false after the first row but pulling all rows of data
- into the client will have a performance impact. If the <i>limit</i> clause is not necessary, it should
- be avoided.
- </note>
- </remarks>
- <returns>A <see cref="MySqlDataReader"/> object.</returns>
-</ExecuteReader1>
-<ExecuteReader>
- <summary>Sends the <see cref="CommandText"/> to the <see cref="MySqlConnection">Connection</see>
- and builds a <see cref="MySqlDataReader"/>.</summary>
- <returns>A <see cref="MySqlDataReader"/> object.</returns>
- <remarks>
- <para>
- When the <see cref="CommandType"/> property is set to <B>StoredProcedure</B>,
- the <see cref="CommandText"/> property should be set to the name of the stored
- procedure. The command executes this stored procedure when you call
- <B>ExecuteReader</B>.
- </para>
- <para>
- While the <see cref="MySqlDataReader"/> is in use, the associated
- <see cref="MySqlConnection"/> is busy serving the <B>MySqlDataReader</B>.
- While in this state, no other operations can be performed on the
- <B>MySqlConnection</B> other than closing it. This is the case until the
- <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
- </para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlCommand"/>, then executes it by
- passing a string that is a SQL SELECT statement, and a string to use to connect to the
- data source.
- <code lang="Visual Basic">
-Public Sub CreateMySqlDataReader(mySelectQuery As String, myConnection As MySqlConnection)
- Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
- myConnection.Open()
- Dim myReader As MySqlDataReader
- myReader = myCommand.ExecuteReader()
- Try
- While myReader.Read()
+
+ <ExecuteNonQuery>
+
+ <summary>
+ Executes a SQL statement against the connection and returns the number of rows affected.
+ </summary>
+ <returns>Number of rows affected</returns>
+ <remarks>
+ You can use ExecuteNonQuery to perform any type of database operation,
+ however any resultsets returned will not be available. Any output parameters
+ used in calling a stored procedure will be populated with data and can be
+ retrieved after execution is complete.
+ For UPDATE, INSERT, and DELETE statements, the return value is the number
+ of rows affected by the command. For all other types of statements, the return
+ value is -1.
+ </remarks>
+ <example>
+ The following example creates a MySqlCommand and then
+ executes it using ExecuteNonQuery. The example is passed a string that is a
+ SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to
+ connect to the data source.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As MySqlConnection)
+ Dim myCommand As New MySqlCommand(myExecuteQuery, myConnection)
+ myCommand.Connection.Open()
+ myCommand.ExecuteNonQuery()
+ myConnection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand(string myExecuteQuery, MySqlConnection myConnection)
+ {
+ MySqlCommand myCommand = new MySqlCommand(myExecuteQuery, myConnection);
+ myCommand.Connection.Open();
+ myCommand.ExecuteNonQuery();
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </ExecuteNonQuery>
+
+ <ExecuteReader1>
+ <summary>
+ Sends the <see cref="CommandText"/> to the <see cref="MySqlConnection">Connection</see>,
+ and builds a <see cref="MySqlDataReader"/> using one of the <see cref="CommandBehavior"/> values.
+ </summary>
+ <param name="behavior">
+ One of the <see cref="CommandBehavior"/> values.
+ </param>
+ <remarks>
+ <para>
+ When the <see cref="CommandType"/> property is set to <B>StoredProcedure</B>,
+ the <see cref="CommandText"/> property should be set to the name of the stored
+ procedure. The command executes this stored procedure when you call
+ <B>ExecuteReader</B>.
+ </para>
+ <para>
+ The <see cref="MySqlDataReader"/> supports a special mode that enables large binary
+ values to be read efficiently. For more information, see the <B>SequentialAccess</B>
+ setting for <see cref="CommandBehavior"/>.
+ </para>
+ <para>
+ While the <see cref="MySqlDataReader"/> is in use, the associated
+ <see cref="MySqlConnection"/> is busy serving the <B>MySqlDataReader</B>.
+ While in this state, no other operations can be performed on the
+ <B>MySqlConnection</B> other than closing it. This is the case until the
+ <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
+ If the <B>MySqlDataReader</B> is created with <B>CommandBehavior</B> set to
+ <B>CloseConnection</B>, closing the <B>MySqlDataReader</B> closes the connection
+ automatically.
+ </para>
+ <note>
+ When calling ExecuteReader with the SingleRow behavior, you should be aware that using a <i>limit</i>
+ clause in your SQL will cause all rows (up to the limit given) to be retrieved by the client. The
+ <see cref="MySqlDataReader.Read"/> method will still return false after the first row but pulling all rows of data
+ into the client will have a performance impact. If the <i>limit</i> clause is not necessary, it should
+ be avoided.
+ </note>
+ </remarks>
+ <returns>
+ A <see cref="MySqlDataReader"/> object.
+ </returns>
+ </ExecuteReader1>
+
+
+ <ExecuteReader>
+ <summary>
+ Sends the <see cref="CommandText"/> to the <see cref="MySqlConnection">Connection</see>
+ and builds a <see cref="MySqlDataReader"/>.
+ </summary>
+ <returns>
+ A <see cref="MySqlDataReader"/> object.
+ </returns>
+ <remarks>
+ <para>
+ When the <see cref="CommandType"/> property is set to <B>StoredProcedure</B>,
+ the <see cref="CommandText"/> property should be set to the name of the stored
+ procedure. The command executes this stored procedure when you call
+ <B>ExecuteReader</B>.
+ </para>
+ <para>
+ While the <see cref="MySqlDataReader"/> is in use, the associated
+ <see cref="MySqlConnection"/> is busy serving the <B>MySqlDataReader</B>.
+ While in this state, no other operations can be performed on the
+ <B>MySqlConnection</B> other than closing it. This is the case until the
+ <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/>, then executes it by
+ passing a string that is a SQL SELECT statement, and a string to use to connect to the
+ data source.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlDataReader(mySelectQuery As String, myConnection As MySqlConnection)
+ Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
+ myConnection.Open()
+ Dim myReader As MySqlDataReader
+ myReader = myCommand.ExecuteReader()
+ Try
+ While myReader.Read()
Console.WriteLine(myReader.GetString(0))
- End While
-Finally
- myReader.Close
- myConnection.Close
- End Try
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlDataReader(string mySelectQuery, MySqlConnection myConnection)
- {
- MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
- myConnection.Open();
- MMySqlDataReader myReader;
- myReader = myCommand.ExecuteReader();
- try
- {
- while(myReader.Read())
- {
+ End While
+ Finally
+ myReader.Close
+ myConnection.Close
+ End Try
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlDataReader(string mySelectQuery, MySqlConnection myConnection)
+ {
+ MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
+ myConnection.Open();
+ MMySqlDataReader myReader;
+ myReader = myCommand.ExecuteReader();
+ try
+ {
+ while(myReader.Read())
+ {
Console.WriteLine(myReader.GetString(0));
- }
- }
- finally
- {
- myReader.Close();
- myConnection.Close();
- }
- }
- </code>
- </example>
-</ExecuteReader>
+ }
+ }
+ finally
+ {
+ myReader.Close();
+ myConnection.Close();
+ }
+ }
+ </code>
+ </example>
+ </ExecuteReader>
-<Prepare>
- <summary>
- Creates a prepared version of the command on an instance of MySQL Server.
- </summary>
- <remarks>
- <para>
- Prepared statements are only supported on MySQL version 4.1 and higher. Calling
- prepare while connected to earlier versions of MySQL will succeed but will execute
- the statement in the same way as unprepared.
- </para>
- </remarks>
- <example>
- The following example demonstrates the use of the <b>Prepare</b> method.
- <code lang="Visual Basic">
- public sub PrepareExample()
- Dim cmd as New MySqlCommand("INSERT INTO mytable VALUES (?val)", myConnection)
- cmd.Parameters.Add( "?val", 10 )
- cmd.Prepare()
- cmd.ExecuteNonQuery()
-
- cmd.Parameters(0).Value = 20
- cmd.ExecuteNonQuery()
- end sub
- </code>
- <code lang="C#">
- private void PrepareExample()
- {
- MySqlCommand cmd = new MySqlCommand("INSERT INTO mytable VALUES (?val)", myConnection);
- cmd.Parameters.Add( "?val", 10 );
- cmd.Prepare();
- cmd.ExecuteNonQuery();
-
- cmd.Parameters[0].Value = 20;
- cmd.ExecuteNonQuery();
- }
- </code>
- </example>
-</Prepare>
+ <Prepare>
+ <summary>
+ Creates a prepared version of the command on an instance of MySQL Server.
+ </summary>
+ <remarks>
+ <para>
+ Prepared statements are only supported on MySQL version 4.1 and higher. Calling
+ prepare while connected to earlier versions of MySQL will succeed but will execute
+ the statement in the same way as unprepared.
+ </para>
+ </remarks>
+ <example>
+ The following example demonstrates the use of the <b>Prepare</b> method.
+ <code lang="Visual Basic">
+ public sub PrepareExample()
+ Dim cmd as New MySqlCommand("INSERT INTO mytable VALUES (?val)", myConnection)
+ cmd.Parameters.Add( "?val", 10 )
+ cmd.Prepare()
+ cmd.ExecuteNonQuery()
-<ExecuteScalar>
- <summary>
- Executes the query, and returns the first column of the first row in the
- result set returned by the query. Extra columns or rows are ignored.
- </summary>
- <returns>
- The first column of the first row in the result set, or a null reference if the
- result set is empty
- </returns>
- <remarks>
- <para>Use the <B>ExecuteScalar</B> method to retrieve a single value (for example,
- an aggregate value) from a database. This requires less code than using the
- <see cref="ExecuteReader"/> method, and then performing the operations necessary
- to generate the single value using the data returned by a <see cref="MySqlDataReader"/>
- </para>
- <para>A typical <B>ExecuteScalar</B> query can be formatted as in the following C#
- example:</para>
-<code lang="C#">
-cmd.CommandText = "select count(*) from region";
-Int32 count = (int32) cmd.ExecuteScalar();
-</code>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlCommand"/> and then
- executes it using <B>ExecuteScalar</B>. The example is passed a string that is a
- SQL statement that returns an aggregate result, and a string to use to
- connect to the data source.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlCommand(myScalarQuery As String, myConnection As MySqlConnection)
- Dim myCommand As New MySqlCommand(myScalarQuery, myConnection)
- myCommand.Connection.Open()
- myCommand.ExecuteScalar()
- myConnection.Close()
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand(string myScalarQuery, MySqlConnection myConnection)
- {
- MySqlCommand myCommand = new MySqlCommand(myScalarQuery, myConnection);
- myCommand.Connection.Open();
- myCommand.ExecuteScalar();
- myConnection.Close();
- }
-</code>
-<code lang="C++">
-public:
- void CreateMySqlCommand(String* myScalarQuery, MySqlConnection* myConnection)
- {
+ cmd.Parameters(0).Value = 20
+ cmd.ExecuteNonQuery()
+ end sub
+ </code>
+ <code lang="C#">
+ private void PrepareExample()
+ {
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO mytable VALUES (?val)", myConnection);
+ cmd.Parameters.Add( "?val", 10 );
+ cmd.Prepare();
+ cmd.ExecuteNonQuery();
+
+ cmd.Parameters[0].Value = 20;
+ cmd.ExecuteNonQuery();
+ }
+ </code>
+ </example>
+ </Prepare>
+
+ <ExecuteScalar>
+ <summary>
+ Executes the query, and returns the first column of the first row in the
+ result set returned by the query. Extra columns or rows are ignored.
+ </summary>
+ <returns>
+ The first column of the first row in the result set, or a null reference if the
+ result set is empty
+ </returns>
+ <remarks>
+ <para>
+ Use the <B>ExecuteScalar</B> method to retrieve a single value (for example,
+ an aggregate value) from a database. This requires less code than using the
+ <see cref="ExecuteReader()"/> method, and then performing the operations necessary
+ to generate the single value using the data returned by a <see cref="MySqlDataReader"/>
+ </para>
+ <para>
+ A typical <B>ExecuteScalar</B> query can be formatted as in the following C#
+ example:
+ </para>
+ <code lang="C#">
+ cmd.CommandText = "select count(*) from region";
+ Int32 count = (int32) cmd.ExecuteScalar();
+ </code>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and then
+ executes it using <B>ExecuteScalar</B>. The example is passed a string that is a
+ SQL statement that returns an aggregate result, and a string to use to
+ connect to the data source.
+
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand(myScalarQuery As String, myConnection As MySqlConnection)
+ Dim myCommand As New MySqlCommand(myScalarQuery, myConnection)
+ myCommand.Connection.Open()
+ myCommand.ExecuteScalar()
+ myConnection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand(string myScalarQuery, MySqlConnection myConnection)
+ {
+ MySqlCommand myCommand = new MySqlCommand(myScalarQuery, myConnection);
+ myCommand.Connection.Open();
+ myCommand.ExecuteScalar();
+ myConnection.Close();
+ }
+ </code>
+ <code lang="C++">
+ public:
+ void CreateMySqlCommand(String* myScalarQuery, MySqlConnection* myConnection)
+ {
MySqlCommand* myCommand = new MySqlCommand(myScalarQuery, myConnection);
myCommand->Connection->Open();
myCommand->ExecuteScalar();
myConnection->Close();
- }
-</code>
-
- </example>
-</ExecuteScalar>
+ }
+ </code>
-<CommandText>
- <summary>
- Gets or sets the SQL statement to execute at the data source.
- </summary>
- <value>
- The SQL statement or stored procedure to execute. The default is an empty string.
- </value>
- <remarks>
- <para>
- When the <see cref="CommandType"/> property is set to <B>StoredProcedure</B>,
- the <B>CommandText</B> property should be set to the name of the stored procedure.
- The user may be required to use escape character syntax if the stored procedure name
- contains any special characters. The command executes this stored procedure when
- you call one of the Execute methods.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim myCommand As New MySqlCommand()
- myCommand.CommandText = "SELECT * FROM Mytable ORDER BY id"
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
- {
- MySqlCommand myCommand = new MySqlCommand();
- myCommand.CommandText = "SELECT * FROM mytable ORDER BY id";
- myCommand.CommandType = CommandType.Text;
- }
-</code>
- </example>
-</CommandText>
+ </example>
+ </ExecuteScalar>
-<CommandTimeout>
- <summary>
- Gets or sets the wait time before terminating the attempt to execute a command
-and generating an error.
- </summary>
- <value>
- The time (in seconds) to wait for the command to execute. The default is 0
-seconds.
- </value>
- <remarks>
- MySQL currently does not support any method of canceling a pending or exeucting operation. All
- commands issues against a MySQL server will execute until completion or exception occurs.
- </remarks>
-</CommandTimeout>
+ <CommandText>
+ <summary>
+ Gets or sets the SQL statement to execute at the data source.
+ </summary>
+ <value>
+ The SQL statement or stored procedure to execute. The default is an empty string.
+ </value>
+ <remarks>
+ <para>
+ When the <see cref="CommandType"/> property is set to <B>StoredProcedure</B>,
+ the <B>CommandText</B> property should be set to the name of the stored procedure.
+ The user may be required to use escape character syntax if the stored procedure name
+ contains any special characters. The command executes this stored procedure when
+ you call one of the Execute methods.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim myCommand As New MySqlCommand()
+ myCommand.CommandText = "SELECT * FROM Mytable ORDER BY id"
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ MySqlCommand myCommand = new MySqlCommand();
+ myCommand.CommandText = "SELECT * FROM mytable ORDER BY id";
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
+ </CommandText>
-<CommandType>
- <summary>Gets or sets a value indicating how the <see cref="CommandText"/> property is to be interpreted.
- </summary>
- <value>
- One of the <see cref="System.Data.CommandType"/> values. The default is <B>Text</B>.
- </value>
- <remarks>
- <para>
- When you set the <B>CommandType</B> property to <B>StoredProcedure</B>, you
- should set the <see cref="CommandText"/> property to the name of the stored
- procedure. The command executes this stored procedure when you call one of the
- Execute methods.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim myCommand As New MySqlCommand()
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
-{
- MySqlCommand myCommand = new MySqlCommand();
- myCommand.CommandType = CommandType.Text;
-}
-</code>
-</example>
-</CommandType>
+ <CommandTimeout>
+ <summary>
+ Gets or sets the wait time before terminating the attempt to execute a command
+ and generating an error.
+ </summary>
+ <value>
+ The time (in seconds) to wait for the command to execute. The default is 0
+ seconds.
+ </value>
+ <remarks>
+ MySQL currently does not support any method of canceling a pending or exeucting operation. All
+ commands issues against a MySQL server will execute until completion or exception occurs.
+ </remarks>
+ </CommandTimeout>
+ <CommandType>
+ <summary>
+ Gets or sets a value indicating how the <see cref="CommandText"/> property is to be interpreted.
+ </summary>
+ <value>
+ One of the <see cref="System.Data.CommandType"/> values. The default is <B>Text</B>.
+ </value>
+ <remarks>
+ <para>
+ When you set the <B>CommandType</B> property to <B>StoredProcedure</B>, you
+ should set the <see cref="CommandText"/> property to the name of the stored
+ procedure. The command executes this stored procedure when you call one of the
+ Execute methods.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim myCommand As New MySqlCommand()
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ MySqlCommand myCommand = new MySqlCommand();
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
+ </CommandType>
-<Connection>
- <summary>
- Gets or sets the <see cref="MySqlConnection"/> used by this instance of the
- <see cref="MySqlCommand"/>.
- </summary>
- <value>
- The connection to a data source. The default value is a null reference
-(<B>Nothing</B> in Visual Basic).
- </value>
- <remarks>
- <para>
- If you set <B>Connection</B> while a transaction is in progress and the
- <see cref="Transaction"/> property is not null, an <see cref="InvalidOperationException"/>
- is generated. If the <B>Transaction</B> property is not null and the transaction
- has already been committed or rolled back, <B>Transaction</B> is set to
- null.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand()
- Dim mySelectQuery As String = "SELECT * FROM mytable ORDER BY id"
- Dim myConnectString As String = "Persist Security Info=False;database=test;server=myServer"
- Dim myCommand As New MySqlCommand(mySelectQuery)
- myCommand.Connection = New MySqlConnection(myConnectString)
- myCommand.CommandType = CommandType.Text
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand()
- {
- string mySelectQuery = "SELECT * FROM mytable ORDER BY id";
- string myConnectString = "Persist Security Info=False;database=test;server=myServer";
- MySqlCommand myCommand = new MySqlCommand(mySelectQuery);
- myCommand.Connection = new MySqlConnection(myConnectString);
- myCommand.CommandType = CommandType.Text;
- }
- </code>
- </example>
-</Connection>
-<IsPrepared>
-</IsPrepared>
+ <Connection>
+ <summary>
+ Gets or sets the <see cref="MySqlConnection"/> used by this instance of the
+ <see cref="MySqlCommand"/>.
+ </summary>
+ <value>
+ The connection to a data source. The default value is a null reference
+ (<B>Nothing</B> in Visual Basic).
+ </value>
+ <remarks>
+ <para>
+ If you set <B>Connection</B> while a transaction is in progress and the
+ <see cref="Transaction"/> property is not null, an <see cref="InvalidOperationException"/>
+ is generated. If the <B>Transaction</B> property is not null and the transaction
+ has already been committed or rolled back, <B>Transaction</B> is set to
+ null.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand()
+ Dim mySelectQuery As String = "SELECT * FROM mytable ORDER BY id"
+ Dim myConnectString As String = "Persist Security Info=False;database=test;server=myServer"
+ Dim myCommand As New MySqlCommand(mySelectQuery)
+ myCommand.Connection = New MySqlConnection(myConnectString)
+ myCommand.CommandType = CommandType.Text
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand()
+ {
+ string mySelectQuery = "SELECT * FROM mytable ORDER BY id";
+ string myConnectString = "Persist Security Info=False;database=test;server=myServer";
+ MySqlCommand myCommand = new MySqlCommand(mySelectQuery);
+ myCommand.Connection = new MySqlConnection(myConnectString);
+ myCommand.CommandType = CommandType.Text;
+ }
+ </code>
+ </example>
+ </Connection>
+ <IsPrepared>
+ </IsPrepared>
-<Parameters>
- <summary>Get the <see cref="MySqlParameterCollection"/></summary>
- <value>The parameters of the SQL statement or stored procedure. The default is
-an empty collection.</value>
- <remarks>
- Connector/Net does not support unnamed parameters. Every parameter added to the collection must
- have an associated name.
- </remarks>
- <example>
-The following example creates a <see cref="MySqlCommand"/> and displays its parameters.
-To accomplish this, the method is passed a <see cref="MySqlConnection"/>, a query string
-that is a SQL SELECT statement, and an array of <see cref="MySqlParameter"/> objects.
-<code lang="Visual Basic">
-Public Sub CreateMySqlCommand(myConnection As MySqlConnection, _
-mySelectQuery As String, myParamArray() As MySqlParameter)
- Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
- myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=?age"
- myCommand.UpdatedRowSource = UpdateRowSource.Both
- myCommand.Parameters.Add(myParamArray)
- Dim j As Integer
- For j = 0 To myCommand.Parameters.Count - 1
- myCommand.Parameters.Add(myParamArray(j))
- Next j
- Dim myMessage As String = ""
- Dim i As Integer
- For i = 0 To myCommand.Parameters.Count - 1
+
+ <Parameters>
+ <summary>
+ Get the <see cref="MySqlParameterCollection"/>
+ </summary>
+ <value>
+ The parameters of the SQL statement or stored procedure. The default is
+ an empty collection.
+ </value>
+ <remarks>
+ Connector/Net does not support unnamed parameters. Every parameter added to the collection must
+ have an associated name.
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and displays its parameters.
+ To accomplish this, the method is passed a <see cref="MySqlConnection"/>, a query string
+ that is a SQL SELECT statement, and an array of <see cref="MySqlParameter"/> objects.
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlCommand(myConnection As MySqlConnection, _
+ mySelectQuery As String, myParamArray() As MySqlParameter)
+ Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
+ myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=?age"
+ myCommand.UpdatedRowSource = UpdateRowSource.Both
+ myCommand.Parameters.Add(myParamArray)
+ Dim j As Integer
+ For j = 0 To myCommand.Parameters.Count - 1
+ myCommand.Parameters.Add(myParamArray(j))
+ Next j
+ Dim myMessage As String = ""
+ Dim i As Integer
+ For i = 0 To myCommand.Parameters.Count - 1
myMessage += myCommand.Parameters(i).ToString() & ControlChars.Cr
- Next i
- Console.WriteLine(myMessage)
-End Sub
-</code>
-<code lang="C#">
-public void CreateMySqlCommand(MySqlConnection myConnection, string mySelectQuery,
- MySqlParameter[] myParamArray)
-{
- MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
- myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=?age";
- myCommand.Parameters.Add(myParamArray);
- for (int j=0; j<myParamArray.Length; j++)
- {
- myCommand.Parameters.Add(myParamArray[j]) ;
- }
- string myMessage = "";
- for (int i = 0; i < myCommand.Parameters.Count; i++)
- {
- myMessage += myCommand.Parameters[i].ToString() + "\n";
- }
- MessageBox.Show(myMessage);
-}
-</code>
-</example>
-</Parameters>
+ Next i
+ Console.WriteLine(myMessage)
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlCommand(MySqlConnection myConnection, string mySelectQuery,
+ MySqlParameter[] myParamArray)
+ {
+ MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
+ myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=?age";
+ myCommand.Parameters.Add(myParamArray);
+ for (int j=0; j<myParamArray.Length; j++)
+ {
+ myCommand.Parameters.Add(myParamArray[j]) ;
+ }
+ string myMessage = "";
+ for (int i = 0; i < myCommand.Parameters.Count; i++)
+ {
+ myMessage += myCommand.Parameters[i].ToString() + "\n";
+ }
+ MessageBox.Show(myMessage);
+ }
+ </code>
+ </example>
+ </Parameters>
-<Transaction>
- <summary>
- Gets or sets the <see cref="MySqlTransaction"/> within which the <see cref="MySqlCommand"/> executes.
- </summary>
- <value>
- The <see cref="MySqlTransaction"/>. The default value is a null reference (<B>Nothing</B> in Visual Basic).
- </value>
- <remarks>
- You cannot set the <B>Transaction</B> property if it is already set to a
- specific value, and the command is in the process of executing. If you set the
- transaction property to a <see cref="MySqlTransaction"/> object that is not connected
- to the same <see cref="MySqlConnection"/> as the <see cref="MySqlCommand"/> object,
- an exception will be thrown the next time you attempt to execute a statement.
- </remarks>
-</Transaction>
+ <Transaction>
+ <summary>
+ Gets or sets the <see cref="MySqlTransaction"/> within which the <see cref="MySqlCommand"/> executes.
+ </summary>
+ <value>
+ The <see cref="MySqlTransaction"/>. The default value is a null reference (<B>Nothing</B> in Visual Basic).
+ </value>
+ <remarks>
+ You cannot set the <B>Transaction</B> property if it is already set to a
+ specific value, and the command is in the process of executing. If you set the
+ transaction property to a <see cref="MySqlTransaction"/> object that is not connected
+ to the same <see cref="MySqlConnection"/> as the <see cref="MySqlCommand"/> object,
+ an exception will be thrown the next time you attempt to execute a statement.
+ </remarks>
+ </Transaction>
-<UpdatedRowSource>
- <summary>
- Gets or sets how command results are applied to the <see cref="DataRow"/>
- when used by the <see cref="System.Data.Common.DbDataAdapter.Update"/> method
- of the <see cref="System.Data.Common.DbDataAdapter"/>.
- </summary>
- <value>One of the <see cref="UpdateRowSource"/> values.</value>
- <remarks>
- <para>
- The default <see cref="System.Data.UpdateRowSource"/> value is
- <B>Both</B> unless the command is automatically generated (as in the case of the
- <see cref="MySqlCommandBuilder"/>), in which case the default is <B>None</B>.
- </para>
- </remarks>
-</UpdatedRowSource>
+ <UpdatedRowSource>
+ <summary>
+ Gets or sets how command results are applied to the <see cref="DataRow"/>
+ when used by the <see cref="System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)"/> method
+ of the <see cref="System.Data.Common.DbDataAdapter"/>.
+ </summary>
+ <value>
+ One of the <see cref="UpdateRowSource"/> values.
+ </value>
+ <remarks>
+ <para>
+ The default <see cref="System.Data.UpdateRowSource"/> value is
+ <B>Both</B> unless the command is automatically generated (as in the case of the
+ <see cref="MySqlCommandBuilder"/>), in which case the default is <B>None</B>.
+ </para>
+ </remarks>
+ </UpdatedRowSource>
</docs>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/docs/MySqlConnection.xml
===================================================================
--- branches/1.0/mysqlclient/docs/MySqlConnection.xml 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/docs/MySqlConnection.xml 2006-10-18 21:25:06 UTC (rev 415)
@@ -1,950 +1,1135 @@
<docs>
-<DefaultCtor>
- <summary>Initializes a new instance of the <see cref="MySqlConnection"/> class.</summary>
- <remarks>
- When a new instance of <see cref="MySqlConnection"/> is created, the read/write
- properties are set to the following initial values unless they are specifically
- set using their associated keywords in the <see cref="ConnectionString"/> property.
- <para/>
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="ConnectionString"/></term><term>empty string ("")</term></item>
- <item><term><see cref="ConnectionTimeout"/></term><term>15</term></item>
- <item><term><see cref="Database"/></term><term>empty string ("")</term></item>
- <item><term><see cref="DataSource"/></term><term>empty string ("")</term></item>
- <item><term><see cref="ServerVersion"/></term><term>empty string ("")</term></item>
- </list>
- <para/>
- You can change the value for these properties only by using the <B>ConnectionString</B> property.
- </remarks>
- <example>
- </example>
- <overloads>
- <summary>Initializes a new instance of the <see cref="MySqlConnection"/> class.</summary>
- </overloads>
-</DefaultCtor>
+ <DefaultCtor>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlConnection"/> class.
+ </summary>
+ <remarks>
+ When a new instance of <see cref="MySqlConnection"/> is created, the read/write
+ properties are set to the following initial values unless they are specifically
+ set using their associated keywords in the <see cref="ConnectionString"/> property.
+ <para/>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="ConnectionString"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="ConnectionTimeout"/>
+ </term>
+ <term>15</term>
+ </item>
+ <item>
+ <term>
+ <see cref="Database"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="DataSource"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="ServerVersion"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ </list>
+ <para/>
+ You can change the value for these properties only by using the <B>ConnectionString</B> property.
+ </remarks>
+ <example>
+ </example>
+ <overloads>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlConnection"/> class.
+ </summary>
+ </overloads>
+ </DefaultCtor>
-<Ctor1>
- <summary>Initializes a new instance of the <see cref="MySqlConnection"/> class when given a string containing the connection string.</summary>
- <remarks>
- When a new instance of <see cref="MySqlConnection"/> is created, the read/write
- properties are set to the following initial values unless they are specifically
- set using their associated keywords in the <see cref="ConnectionString"/> property.
- <para/>
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="ConnectionString"/></term><term>empty string ("")</term></item>
- <item><term><see cref="ConnectionTimeout"/></term><term>15</term></item>
- <item><term><see cref="Database"/></term><term>empty string ("")</term></item>
- <item><term><see cref="DataSource"/></term><term>empty string ("")</term></item>
- <item><term><see cref="ServerVersion"/></term><term>empty string ("")</term></item>
- </list>
- <para/>
- You can change the value for these properties only by using the <B>ConnectionString</B> property.
- </remarks>
- <example>
- </example>
- <param name="connectionString">The connection properties used to open the MySQL database. </param>
-</Ctor1>
+ <Ctor1>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlConnection"/> class when given a string containing the connection string.
+ </summary>
+ <remarks>
+ When a new instance of <see cref="MySqlConnection"/> is created, the read/write
+ properties are set to the following initial values unless they are specifically
+ set using their associated keywords in the <see cref="ConnectionString"/> property.
+ <para/>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="ConnectionString"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="ConnectionTimeout"/>
+ </term>
+ <term>15</term>
+ </item>
+ <item>
+ <term>
+ <see cref="Database"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="DataSource"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ <item>
+ <term>
+ <see cref="ServerVersion"/>
+ </term>
+ <term>empty string ("")</term>
+ </item>
+ </list>
+ <para/>
+ You can change the value for these properties only by using the <B>ConnectionString</B> property.
+ </remarks>
+ <example>
+ </example>
+ <param name="connectionString">The connection properties used to open the MySQL database. </param>
+ </Ctor1>
-<Open>
- <summary>Opens a database connection with the property settings specified by the ConnectionString.</summary>
- <exception cref="InvalidOperationException">Cannot open a connection without specifying a data source or server.</exception>
- <exception cref="MySqlException">A connection-level error occurred while opening the connection.</exception>
- <remarks>
- <para>The <see cref="MySqlConnection"/> draws an open connection from the connection pool if one is available.
- Otherwise, it establishes a new connection to an instance of MySQL.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/>, opens it,
- displays some of its properties, then closes the connection.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlConnection(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
- + ControlChars.Cr + "State: " + myConnection.State.ToString())
- myConnection.Close()
-End Sub
- </code>
- <code lang="C#">
-public void CreateMySqlConnection(string myConnString)
-{
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
- "\nState: " + myConnection.State.ToString());
- myConnection.Close();
-}
- </code>
- </example>
-</Open>
+ <Open>
+ <summary>Opens a database connection with the property settings specified by the ConnectionString.</summary>
+ <exception cref="InvalidOperationException">Cannot open a connection without specifying a data source or server.</exception>
+ <exception cref="MySqlException">A connection-level error occurred while opening the connection.</exception>
+ <remarks>
+ <para>
+ The <see cref="MySqlConnection"/> draws an open connection from the connection pool if one is available.
+ Otherwise, it establishes a new connection to an instance of MySQL.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/>, opens it,
+ displays some of its properties, then closes the connection.
-<Database>
- <summary>Gets the name of the current database or the database to be used after a connection is opened.</summary>
- <returns>The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.</returns>
- <remarks>
- <para>The <B>Database</B> property does not update dynamically.
- If you change the current database using a SQL statement, then this property
- may reflect the wrong value. If you change the current database using the <see cref="ChangeDatabase"/>
- method, this property is updated to reflect the new database.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/> and displays
- some of its read-only properties.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlConnection()
- Dim myConnString As String = _
- "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"
- Dim myConnection As New MySqlConnection( myConnString )
- myConnection.Open()
- MessageBox.Show( "Server Version: " + myConnection.ServerVersion _
- + ControlChars.NewLine + "Database: " + myConnection.Database )
- myConnection.ChangeDatabase( "test2" )
- MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _
- + ControlChars.NewLine + "Database: " + myConnection.Database )
- myConnection.Close()
-End Sub
- </code>
-
- <code lang="C#">
-public void CreateMySqlConnection()
-{
- string myConnString =
- "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass";
- MySqlConnection myConnection = new MySqlConnection( myConnString );
- myConnection.Open();
- MessageBox.Show( "Server Version: " + myConnection.ServerVersion
- + "\nDatabase: " + myConnection.Database );
- myConnection.ChangeDatabase( "test2" );
- MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion
- + "\nDatabase: " + myConnection.Database );
- myConnection.Close();
-}
- </code>
- </example>
-</Database>
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlConnection(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
+ + ControlChars.Cr + "State: " + myConnection.State.ToString())
+ myConnection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlConnection(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
+ "\nState: " + myConnection.State.ToString());
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </Open>
-<State>
- <summary>Gets the current state of the connection.</summary>
- <returns>A bitwise combination of the <see cref="System.Data.ConnectionState"/> values. The default is <B>Closed</B>.</returns>
- <remarks>
- The allowed state changes are:
- <list type="bullet">
- <item>From <B>Closed</B> to <B>Open</B>, using the <B>Open</B> method of the connection object.</item>
- <item>From <B>Open</B> to <B>Closed</B>, using either the <B>Close</B> method or the <B>Dispose</B> method of the connection object. </item>
- </list>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/>, opens it,
- displays some of its properties, then closes the connection.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlConnection(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
- + ControlChars.Cr + "State: " + myConnection.State.ToString())
- myConnection.Close()
-End Sub
- </code>
- <code lang="C#">
-public void CreateMySqlConnection(string myConnString)
-{
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
- "\nState: " + myConnection.State.ToString());
- myConnection.Close();
-}
- </code>
- </example>
-</State>
+ <Database>
+ <summary>Gets the name of the current database or the database to be used after a connection is opened.</summary>
+ <returns>The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.</returns>
+ <remarks>
+ <para>
+ The <B>Database</B> property does not update dynamically.
+ If you change the current database using a SQL statement, then this property
+ may reflect the wrong value. If you change the current database using the <see cref="ChangeDatabase"/>
+ method, this property is updated to reflect the new database.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> and displays
+ some of its read-only properties.
-<ServerVersion>
- <summary>Gets a string containing the version of the MySQL server to which the client is connected.</summary>
- <returns>The version of the instance of MySQL.</returns>
- <exception cref="InvalidOperationException">The connection is closed.</exception>
- <example>
- The following example creates a <see cref="MySqlConnection"/>, opens it,
- displays some of its properties, then closes the connection.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlConnection(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
- + ControlChars.Cr + "State: " + myConnection.State.ToString())
- myConnection.Close()
-End Sub
- </code>
- <code lang="C#">
-public void CreateMySqlConnection(string myConnString)
-{
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
- "\nState: " + myConnection.State.ToString());
- myConnection.Close();
-}
- </code>
- </example>
-</ServerVersion>
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlConnection()
+ Dim myConnString As String = _
+ "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"
+ Dim myConnection As New MySqlConnection( myConnString )
+ myConnection.Open()
+ MessageBox.Show( "Server Version: " + myConnection.ServerVersion _
+ + ControlChars.NewLine + "Database: " + myConnection.Database )
+ myConnection.ChangeDatabase( "test2" )
+ MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _
+ + ControlChars.NewLine + "Database: " + myConnection.Database )
+ myConnection.Close()
+ End Sub
+ </code>
-<Close>
- <summary>Closes the connection to the database. This is the preferred method of closing any open connection.</summary>
- <remarks>
- <para>The <B>Close</B> method rolls back any pending transactions. It then releases
- the connection to the connection pool, or closes the connection if connection
- pooling is disabled.</para>
- <para>An application can call <B>Close</B> more than one time. No exception is
- generated.</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/>, opens it,
- displays some of its properties, then closes the connection.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlConnection(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
- + ControlChars.Cr + "State: " + myConnection.State.ToString())
- myConnection.Close()
-End Sub
- </code>
- <code lang="C#">
-public void CreateMySqlConnection(string myConnString)
-{
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
- MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
- "\nState: " + myConnection.State.ToString());
- myConnection.Close();
-}
- </code>
- </example>
-</Close>
+ <code lang="C#">
+ public void CreateMySqlConnection()
+ {
+ string myConnString =
+ "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass";
+ MySqlConnection myConnection = new MySqlConnection( myConnString );
+ myConnection.Open();
+ MessageBox.Show( "Server Version: " + myConnection.ServerVersion
+ + "\nDatabase: " + myConnection.Database );
+ myConnection.ChangeDatabase( "test2" );
+ MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion
+ + "\nDatabase: " + myConnection.Database );
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </Database>
-<CreateCommand>
- <summary>Creates and returns a <see cref="MySqlCommand"/> object associated with the <see cref="MySqlConnection"/>.</summary>
- <returns>A <see cref="MySqlCommand"/> object.</returns>
-</CreateCommand>
+ <State>
+ <summary>Gets the current state of the connection.</summary>
+ <returns>
+ A bitwise combination of the <see cref="System.Data.ConnectionState"/> values. The default is <B>Closed</B>.
+ </returns>
+ <remarks>
+ The allowed state changes are:
+ <list type="bullet">
+ <item>
+ From <B>Closed</B> to <B>Open</B>, using the <B>Open</B> method of the connection object.
+ </item>
+ <item>
+ From <B>Open</B> to <B>Closed</B>, using either the <B>Close</B> method or the <B>Dispose</B> method of the connection object.
+ </item>
+ </list>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/>, opens it,
+ displays some of its properties, then closes the connection.
-<BeginTransaction>
- <summary>Begins a database transaction.</summary>
- <returns>An object representing the new transaction.</returns>
- <exception cref="InvalidOperationException">Parallel transactions are not supported.</exception>
- <remarks>
- <para>This command is equivalent to the MySQL BEGIN TRANSACTION command.</para>
- <para>You must explicitly commit or roll back the transaction using the <see cref="MySqlTransaction.Commit"/> or
- <see cref="MySqlTransaction.Rollback"/> method.
- <note>If you do not specify an isolation level, the default isolation level is used. To specify an isolation
- level with the <see cref="BeginTransaction"/> method, use the overload that takes the <I>iso</I> parameter.
- </note></para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/> and a
- <see cref="MySqlTransaction"/>. It also demonstrates how to use the <B>BeginTransaction</B>, a
- <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
- <code lang="Visual Basic">
-Public Sub RunTransaction(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
-
- Dim myCommand As MySqlCommand = myConnection.CreateCommand()
- Dim myTrans As MySqlTransaction
-
- ' Start a local transaction
- myTrans = myConnection.BeginTransaction()
- ' Must assign both transaction object and connection
- ' to Command object for a pending local transaction
- myCommand.Connection = myConnection
- myCommand.Transaction = myTrans
-
- Try
- myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')"
- myCommand.ExecuteNonQuery()
- myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')"
- myCommand.ExecuteNonQuery()
- myTrans.Commit()
- Console.WriteLine("Both records are written to database.")
- Catch e As Exception
- Try
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlConnection(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
+ + ControlChars.Cr + "State: " + myConnection.State.ToString())
+ myConnection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlConnection(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
+ "\nState: " + myConnection.State.ToString());
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </State>
+
+ <ServerVersion>
+ <summary>Gets a string containing the version of the MySQL server to which the client is connected.</summary>
+ <returns>The version of the instance of MySQL.</returns>
+ <exception cref="InvalidOperationException">The connection is closed.</exception>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/>, opens it,
+ displays some of its properties, then closes the connection.
+
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlConnection(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
+ + ControlChars.Cr + "State: " + myConnection.State.ToString())
+ myConnection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlConnection(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
+ "\nState: " + myConnection.State.ToString());
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </ServerVersion>
+
+ <Close>
+ <summary>Closes the connection to the database. This is the preferred method of closing any open connection.</summary>
+ <remarks>
+ <para>
+ The <B>Close</B> method rolls back any pending transactions. It then releases
+ the connection to the connection pool, or closes the connection if connection
+ pooling is disabled.
+ </para>
+ <para>
+ An application can call <B>Close</B> more than one time. No exception is
+ generated.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/>, opens it,
+ displays some of its properties, then closes the connection.
+
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlConnection(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
+ + ControlChars.Cr + "State: " + myConnection.State.ToString())
+ myConnection.Close()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateMySqlConnection(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
+ MessageBox.Show("ServerVersion: " + myConnection.ServerVersion +
+ "\nState: " + myConnection.State.ToString());
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </Close>
+
+ <CreateCommand>
+ <summary>
+ Creates and returns a <see cref="MySqlCommand"/> object associated with the <see cref="MySqlConnection"/>.
+ </summary>
+ <returns>
+ A <see cref="MySqlCommand"/> object.
+ </returns>
+ </CreateCommand>
+
+ <BeginTransaction>
+ <summary>Begins a database transaction.</summary>
+ <returns>An object representing the new transaction.</returns>
+ <exception cref="InvalidOperationException">Parallel transactions are not supported.</exception>
+ <remarks>
+ <para>This command is equivalent to the MySQL BEGIN TRANSACTION command.</para>
+ <para>
+ You must explicitly commit or roll back the transaction using the <see cref="MySqlTransaction.Commit"/> or
+ <see cref="MySqlTransaction.Rollback"/> method.
+ <note>
+ If you do not specify an isolation level, the default isolation level is used. To specify an isolation
+ level with the <see cref="BeginTransaction()"/> method, use the overload that takes the <I>iso</I> parameter.
+ </note>
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> and a
+ <see cref="MySqlTransaction"/>. It also demonstrates how to use the <B>BeginTransaction</B>, a
+ <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
+ <code lang="Visual Basic">
+ Public Sub RunTransaction(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+
+ Dim myCommand As MySqlCommand = myConnection.CreateCommand()
+ Dim myTrans As MySqlTransaction
+
+ ' Start a local transaction
+ myTrans = myConnection.BeginTransaction()
+ ' Must assign both transaction object and connection
+ ' to Command object for a pending local transaction
+ myCommand.Connection = myConnection
+ myCommand.Transaction = myTrans
+
+ Try
+ myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myTrans.Commit()
+ Console.WriteLine("Both records are written to database.")
+ Catch e As Exception
+ Try
myTrans.Rollback()
- Catch ex As MySqlException
+ Catch ex As MySqlException
If Not myTrans.Connection Is Nothing Then
- Console.WriteLine("An exception of type " + ex.GetType().ToString() + _
- " was encountered while attempting to roll back the transaction.")
+ Console.WriteLine("An exception of type " + ex.GetType().ToString() + _
+ " was encountered while attempting to roll back the transaction.")
End If
- End Try
-
- Console.WriteLine("An exception of type " + e.GetType().ToString() + _
- "was encountered while inserting the data.")
- Console.WriteLine("Neither record was written to database.")
- Finally
- myConnection.Close()
- End Try
-End Sub
- </code>
- <code lang="C#">
-public void RunTransaction(string myConnString)
-{
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
+ End Try
- MySqlCommand myCommand = myConnection.CreateCommand();
- MySqlTransaction myTrans;
+ Console.WriteLine("An exception of type " + e.GetType().ToString() + _
+ "was encountered while inserting the data.")
+ Console.WriteLine("Neither record was written to database.")
+ Finally
+ myConnection.Close()
+ End Try
+ End Sub
+ </code>
+ <code lang="C#">
+ public void RunTransaction(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
- // Start a local transaction
- myTrans = myConnection.BeginTransaction();
- // Must assign both transaction object and connection
- // to Command object for a pending local transaction
- myCommand.Connection = myConnection;
- myCommand.Transaction = myTrans;
+ MySqlCommand myCommand = myConnection.CreateCommand();
+ MySqlTransaction myTrans;
- try
- {
- myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')";
- myCommand.ExecuteNonQuery();
- myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')";
- myCommand.ExecuteNonQuery();
- myTrans.Commit();
- Console.WriteLine("Both records are written to database.");
- }
- catch(Exception e)
- {
- try
- {
+ // Start a local transaction
+ myTrans = myConnection.BeginTransaction();
+ // Must assign both transaction object and connection
+ // to Command object for a pending local transaction
+ myCommand.Connection = myConnection;
+ myCommand.Transaction = myTrans;
+
+ try
+ {
+ myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myTrans.Commit();
+ Console.WriteLine("Both records are written to database.");
+ }
+ catch(Exception e)
+ {
+ try
+ {
myTrans.Rollback();
- }
- catch (SqlException ex)
- {
+ }
+ catch (SqlException ex)
+ {
if (myTrans.Connection != null)
{
- Console.WriteLine("An exception of type " + ex.GetType() +
- " was encountered while attempting to roll back the transaction.");
+ Console.WriteLine("An exception of type " + ex.GetType() +
+ " was encountered while attempting to roll back the transaction.");
}
- }
-
- Console.WriteLine("An exception of type " + e.GetType() +
- " was encountered while inserting the data.");
- Console.WriteLine("Neither record was written to database.");
- }
- finally
- {
- myConnection.Close();
- }
-}
- </code>
- </example>
-</BeginTransaction>
+ }
-<BeginTransaction1>
- <summary>Begins a database transaction with the specified isolation level.</summary>
- <param name="iso">The isolation level under which the transaction should run. </param>
- <returns>An object representing the new transaction.</returns>
- <exception cref="InvalidOperationException">Parallel exceptions are not supported.</exception>
- <remarks>
- <para>This command is equivalent to the MySQL BEGIN TRANSACTION command.</para>
- <para>You must explicitly commit or roll back the transaction using the <see cref="MySqlTransaction.Commit"/> or
- <see cref="MySqlTransaction.Rollback"/> method.
- <note>If you do not specify an isolation level, the default isolation level is used. To specify an isolation
- level with the <see cref="BeginTransaction"/> method, use the overload that takes the <I>iso</I> parameter.
- </note></para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/> and a
- <see cref="MySqlTransaction"/>. It also demonstrates how to use the <B>BeginTransaction</B>, a
- <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
- <code lang="Visual Basic">
-Public Sub RunTransaction(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
-
- Dim myCommand As MySqlCommand = myConnection.CreateCommand()
- Dim myTrans As MySqlTransaction
-
- ' Start a local transaction
- myTrans = myConnection.BeginTransaction()
- ' Must assign both transaction object and connection
- ' to Command object for a pending local transaction
- myCommand.Connection = myConnection
- myCommand.Transaction = myTrans
-
- Try
- myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')"
- myCommand.ExecuteNonQuery()
- myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')"
- myCommand.ExecuteNonQuery()
- myTrans.Commit()
- Console.WriteLine("Both records are written to database.")
- Catch e As Exception
- Try
+ Console.WriteLine("An exception of type " + e.GetType() +
+ " was encountered while inserting the data.");
+ Console.WriteLine("Neither record was written to database.");
+ }
+ finally
+ {
+ myConnection.Close();
+ }
+ }
+ </code>
+ </example>
+ </BeginTransaction>
+
+ <BeginTransaction1>
+ <summary>Begins a database transaction with the specified isolation level.</summary>
+ <param name="iso">The isolation level under which the transaction should run. </param>
+ <returns>An object representing the new transaction.</returns>
+ <exception cref="InvalidOperationException">Parallel exceptions are not supported.</exception>
+ <remarks>
+ <para>This command is equivalent to the MySQL BEGIN TRANSACTION command.</para>
+ <para>
+ You must explicitly commit or roll back the transaction using the <see cref="MySqlTransaction.Commit"/> or
+ <see cref="MySqlTransaction.Rollback"/> method.
+ <note>
+ If you do not specify an isolation level, the default isolation level is used. To specify an isolation
+ level with the <see cref="BeginTransaction()"/> method, use the overload that takes the <I>iso</I> parameter.
+ </note>
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> and a
+ <see cref="MySqlTransaction"/>. It also demonstrates how to use the <B>BeginTransaction</B>, a
+ <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
+ <code lang="Visual Basic">
+ Public Sub RunTransaction(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+
+ Dim myCommand As MySqlCommand = myConnection.CreateCommand()
+ Dim myTrans As MySqlTransaction
+
+ ' Start a local transaction
+ myTrans = myConnection.BeginTransaction()
+ ' Must assign both transaction object and connection
+ ' to Command object for a pending local transaction
+ myCommand.Connection = myConnection
+ myCommand.Transaction = myTrans
+
+ Try
+ myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myTrans.Commit()
+ Console.WriteLine("Both records are written to database.")
+ Catch e As Exception
+ Try
myTrans.Rollback()
- Catch ex As MySqlException
+ Catch ex As MySqlException
If Not myTrans.Connection Is Nothing Then
- Console.WriteLine("An exception of type " + ex.GetType().ToString() + _
- " was encountered while attempting to roll back the transaction.")
+ Console.WriteLine("An exception of type " + ex.GetType().ToString() + _
+ " was encountered while attempting to roll back the transaction.")
End If
- End Try
-
- Console.WriteLine("An exception of type " + e.GetType().ToString() + _
- "was encountered while inserting the data.")
- Console.WriteLine("Neither record was written to database.")
- Finally
- myConnection.Close()
- End Try
-End Sub
- </code>
- <code lang="C#">
-public void RunTransaction(string myConnString)
-{
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
+ End Try
- MySqlCommand myCommand = myConnection.CreateCommand();
- MySqlTransaction myTrans;
+ Console.WriteLine("An exception of type " + e.GetType().ToString() + _
+ "was encountered while inserting the data.")
+ Console.WriteLine("Neither record was written to database.")
+ Finally
+ myConnection.Close()
+ End Try
+ End Sub
+ </code>
+ <code lang="C#">
+ public void RunTransaction(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
- // Start a local transaction
- myTrans = myConnection.BeginTransaction();
- // Must assign both transaction object and connection
- // to Command object for a pending local transaction
- myCommand.Connection = myConnection;
- myCommand.Transaction = myTrans;
+ MySqlCommand myCommand = myConnection.CreateCommand();
+ MySqlTransaction myTrans;
- try
- {
- myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')";
- myCommand.ExecuteNonQuery();
- myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')";
- myCommand.ExecuteNonQuery();
- myTrans.Commit();
- Console.WriteLine("Both records are written to database.");
- }
- catch(Exception e)
- {
- try
- {
+ // Start a local transaction
+ myTrans = myConnection.BeginTransaction();
+ // Must assign both transaction object and connection
+ // to Command object for a pending local transaction
+ myCommand.Connection = myConnection;
+ myCommand.Transaction = myTrans;
+
+ try
+ {
+ myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myTrans.Commit();
+ Console.WriteLine("Both records are written to database.");
+ }
+ catch(Exception e)
+ {
+ try
+ {
myTrans.Rollback();
- }
- catch (SqlException ex)
- {
+ }
+ catch (SqlException ex)
+ {
if (myTrans.Connection != null)
{
- Console.WriteLine("An exception of type " + ex.GetType() +
- " was encountered while attempting to roll back the transaction.");
+ Console.WriteLine("An exception of type " + ex.GetType() +
+ " was encountered while attempting to roll back the transaction.");
}
- }
-
- Console.WriteLine("An exception of type " + e.GetType() +
- " was encountered while inserting the data.");
- Console.WriteLine("Neither record was written to database.");
- }
- finally
- {
- myConnection.Close();
- }
-}
- </code>
- </example>
-</BeginTransaction1>
+ }
-<ChangeDatabase>
- <summary>Changes the current database for an open MySqlConnection.</summary>
- <param name="databaseName">The name of the database to use.</param>
- <remarks>
- <para>The value supplied in the <I>database</I> parameter must be a valid database
- name. The <I>database</I> parameter cannot contain a null value, an empty
- string, or a string with only blank characters.</para>
-
- <para>When you are using connection pooling against MySQL, and you close
- the connection, it is returned to the connection pool. The next time the
- connection is retrieved from the pool, the reset connection request
- executes before the user performs any operations.</para>
- </remarks>
- <exception cref="ArgumentException">The database name is not valid.</exception>
- <exception cref="InvalidOperationException">The connection is not open.</exception>
- <exception cref="MySqlException">Cannot change the database.</exception>
- <example>
- The following example creates a <see cref="MySqlConnection"/> and displays
- some of its read-only properties.
-
- <code lang="Visual Basic">
-Public Sub CreateMySqlConnection()
- Dim myConnString As String = _
- "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"
- Dim myConnection As New MySqlConnection( myConnString )
- myConnection.Open()
- MessageBox.Show( "Server Version: " + myConnection.ServerVersion _
- + ControlChars.NewLine + "Database: " + myConnection.Database )
- myConnection.ChangeDatabase( "test2" )
- MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _
- + ControlChars.NewLine + "Database: " + myConnection.Database )
- myConnection.Close()
-End Sub
- </code>
-
- <code lang="C#">
-public void CreateMySqlConnection()
-{
- string myConnString =
- "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass";
- MySqlConnection myConnection = new MySqlConnection( myConnString );
- myConnection.Open();
- MessageBox.Show( "Server Version: " + myConnection.ServerVersion
- + "\nDatabase: " + myConnection.Database );
- myConnection.ChangeDatabase( "test2" );
- MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion
- + "\nDatabase: " + myConnection.Database );
- myConnection.Close();
-}
- </code>
- </example>
-</ChangeDatabase>
+ Console.WriteLine("An exception of type " + e.GetType() +
+ " was encountered while inserting the data.");
+ Console.WriteLine("Neither record was written to database.");
+ }
+ finally
+ {
+ myConnection.Close();
+ }
+ }
+ </code>
+ </example>
+ </BeginTransaction1>
-<StateChange>
- <summary>Occurs when the state of the connection changes.</summary>
- <remarks>
- <para>The <B>StateChange</B> event fires whenever the <see cref="State"/> changes from
- closed to opened, or from opened to closed. <B>StateChange</B> fires immediately
- after the <see cref="MySqlConnection"/> transitions.</para>
-
- <para>If an event handler throws an exception from within the <B>StateChange</B>
- event, the exception propagates to the caller of the <see cref="Open"/> or
- <see cref="Close"/> method.</para>
-
- <para>The <B>StateChange</B> event is not raised unless you explicitly call
- <B>Close</B> or <B>Dispose</B>.</para>
- </remarks>
- <event cref="StateChange">
- Raised.
- <data>
- <para>The event handler receives an argument of type <see cref="System.Data.StateChangeEventArgs"/>
- containing data related to this event. The following <B>StateChangeEventArgs</B>
- properties provide information specific to this event.</para>
- <list type="table">
- <listheader>
- <term>Property</term>
- <description>Description</description>
- </listheader>
- <item>
- <term><see cref="System.Data.StateChangeEventArgs.CurrentState"/></term>
- <description>Gets the new state of the connection. The connection object will
- be in the new state already when the event is fired.</description>
- </item>
- <item>
- <term><see cref="System.Data.StateChangeEventArgs.OriginalState"/></term>
- <description>Gets the original state of the connection.</description>
- </item>
- </list>
- </data>
- </event>
-</StateChange>
+ <ChangeDatabase>
+ <summary>Changes the current database for an open MySqlConnection.</summary>
+ <param name="databaseName">The name of the database to use.</param>
+ <remarks>
+ <para>
+ The value supplied in the <I>database</I> parameter must be a valid database
+ name. The <I>database</I> parameter cannot contain a null value, an empty
+ string, or a string with only blank characters.
+ </para>
-<InfoMessage>
- <summary>Occurs when MySQL returns warnings as a result of executing a command or query.</summary>
- <remarks>
- </remarks>
-</InfoMessage>
+ <para>
+ When you are using connection pooling against MySQL, and you close
+ the connection, it is returned to the connection pool. The next time the
+ connection is retrieved from the pool, the reset connection request
+ executes before the user performs any operations.
+ </para>
+ </remarks>
+ <exception cref="ArgumentException">The database name is not valid.</exception>
+ <exception cref="InvalidOperationException">The connection is not open.</exception>
+ <exception cref="MySqlException">Cannot change the database.</exception>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> and displays
+ some of its read-only properties.
-<ClassSummary>
- <summary>
- Represents an open connection to a MySQL Server database. This class cannot be inherited.
- </summary>
- <remarks>
- <para>
- A <b>MySqlConnection</b> object represents a session to a MySQL Server
- data source. When you create an instance of <B>MySqlConnection</B>, all
- properties are set to their initial values. For a list of these values, see the
- <B>MySqlConnection</B> constructor.
- </para>
-
- <para>
- If the <B>MySqlConnection</B> goes out of scope, it is not closed. Therefore,
- you must explicitly close the connection by calling <see cref="MySqlConnection.Close"/>
- or <see cref="MySqlConnection.Dispose"/>.
- </para>
- </remarks>
+ <code lang="Visual Basic">
+ Public Sub CreateMySqlConnection()
+ Dim myConnString As String = _
+ "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"
+ Dim myConnection As New MySqlConnection( myConnString )
+ myConnection.Open()
+ MessageBox.Show( "Server Version: " + myConnection.ServerVersion _
+ + ControlChars.NewLine + "Database: " + myConnection.Database )
+ myConnection.ChangeDatabase( "test2" )
+ MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _
+ + ControlChars.NewLine + "Database: " + myConnection.Database )
+ myConnection.Close()
+ End Sub
+ </code>
- <example>
- The following example creates a <see cref="MySqlCommand"/> and
- a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the
- <see cref="MySqlCommand.Connection"/> for the <B>MySqlCommand</B>. The example then calls
- <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
- passed a connection string and a query string that is a SQL INSERT
- statement.
- <code lang="Visual Basic">
- <c>
- Public Sub InsertRow(myConnectionString As String)
- ' If the connection string is null, use a default.
- If myConnectionString = "" Then
- myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"
- End If
- Dim myConnection As New MySqlConnection(myConnectionString)
- Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"
- Dim myCommand As New MySqlCommand(myInsertQuery)
- myCommand.Connection = myConnection
- myConnection.Open()
- myCommand.ExecuteNonQuery()
- myCommand.Connection.Close()
- End Sub
- </c>
- </code>
- <code lang="C#">
- <c>
- public void InsertRow(string myConnectionString)
- {
- // If the connection string is null, use a default.
- if(myConnectionString == "")
- {
- myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";
- }
- MySqlConnection myConnection = new MySqlConnection(myConnectionString);
- string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";
- MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
- myCommand.Connection = myConnection;
- myConnection.Open();
- myCommand.ExecuteNonQuery();
- myCommand.Connection.Close();
- }
- </c>
- </code>
- </example>
-</ClassSummary>
+ <code lang="C#">
+ public void CreateMySqlConnection()
+ {
+ string myConnString =
+ "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass";
+ MySqlConnection myConnection = new MySqlConnection( myConnString );
+ myConnection.Open();
+ MessageBox.Show( "Server Version: " + myConnection.ServerVersion
+ + "\nDatabase: " + myConnection.Database );
+ myConnection.ChangeDatabase( "test2" );
+ MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion
+ + "\nDatabase: " + myConnection.Database );
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </ChangeDatabase>
-<ConnectionTimeout>
- <summary>
- Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
- </summary>
- <exception cref="System.ArgumentException">The value set is less than 0.</exception>
- <remarks>
- A value of 0 indicates no limit, and should be avoided in a
- <see cref="MySqlConnection.ConnectionString"/> because an attempt to connect
- will wait indefinitely.
- </remarks>
- <example>
- The following example creates a MySqlConnection
- and sets some of its properties in the connection string.
- <code lang="Visual Basic">
-Public Sub CreateSqlConnection()
- Dim myConnection As New MySqlConnection()
- myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"
- myConnection.Open()
-End Sub
-</code>
-<code lang="C#">
-public void CreateSqlConnection()
-{
- MySqlConnection myConnection = new MySqlConnection();
- myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";
- myConnection.Open();
-}
-</code>
- </example>
-</ConnectionTimeout>
+ <StateChange>
+ <summary>Occurs when the state of the connection changes.</summary>
+ <remarks>
+ <para>
+ The <B>StateChange</B> event fires whenever the <see cref="State"/> changes from
+ closed to opened, or from opened to closed. <B>StateChange</B> fires immediately
+ after the <see cref="MySqlConnection"/> transitions.
+ </para>
+ <para>
+ If an event handler throws an exception from within the <B>StateChange</B>
+ event, the exception propagates to the caller of the <see cref="Open"/> or
+ <see cref="Close"/> method.
+ </para>
-<ConnectionString>
- <summary>
- Gets or sets the string used to connect to a MySQL Server database.
- </summary>
- <remarks>
- <para>The <B>ConnectionString</B> returned may not be exactly like what was originally
- set but will be indentical in terms of keyword/value pairs. Security information
- will not be included unless the Persist Security Info value is set to true.
- </para>
- <para>You can use the <B>ConnectionString</B> property to connect to a database.
- The following example illustrates a typical connection string.</para>
- <c>"Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass"</c>
- <para>The <B>ConnectionString</B> property can be set only when the connection is
- closed. Many of the connection string values have corresponding read-only
- properties. When the connection string is set, all of these properties are
- updated, except when an error is detected. In this case, none of the properties
- are updated. <see cref="MySqlConnection"/> properties return only those settings contained in the
- <B>ConnectionString</B>.</para>
- <para>To connect to a local machine, specify "localhost" for the server. If you do not
- specify a server, localhost is assumed.</para>
- <para>Resetting the <B>ConnectionString</B> on a closed connection resets all
- connection string values (and related properties) including the password. For
- example, if you set a connection string that includes "Database= MyDb", and
- then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass",
- the <see cref="MySqlConnection.Database"/> property is no longer set to MyDb.</para>
- <para>The connection string is parsed immediately after being set. If errors in
- syntax are found when parsing, a runtime exception, such as <see cref="ArgumentException"/>,
- is generated. Other errors can be found only when an attempt is made to open the
- connection.</para>
- <para>The basic format of a connection string consists of a series of keyword/value
- pairs separated by semicolons. The equal sign (=) connects each keyword and its
- value. To include values that contain a semicolon, single-quote character, or
- double-quote character, the value must be enclosed in double quotes. If the
- value contains both a semicolon and a double-quote character, the value can be
- enclosed in single quotes. The single quote is also useful if the value begins
- with a double-quote character. Conversely, the double quote can be used if the
- value begins with a single quote. If the value contains both single-quote and
- double-quote characters, the quote character used to enclose the value must be
- doubled each time it occurs within the value.</para>
- <para>To include preceding or trailing spaces in the string value, the value must
- be enclosed in either single quotes or double quotes. Any leading or trailing
- spaces around integer, Boolean, or enumerated values are ignored, even if
- enclosed in quotes. However, spaces within a string literal keyword or value are
- preserved. Using .NET Framework version 1.1, single or double quotes may be used
- within a connection string without using delimiters (for example, Data Source=
- my'Server or Data Source= my"Server), unless a quote character is the first or
- last character in the value.</para>
- <para>To include an equal sign (=) in a keyword or value, it must be preceded by
- another equal sign. For example, in the hypothetical connection string</para>
- <c>"key==word=value"</c>
- <para></para>
- <para>the keyword is "key=word" and the value is "value".</para>
- <para>If a specific keyword in a keyword= value pair occurs multiple times in a
- connection string, the last occurrence listed is used in the value set.</para>
- <para>Keywords are not case sensitive.</para>
- <para>The following table lists the valid names for keyword values within the
- <B>ConnectionString</B>.</para>
-
- <div class="tablediv"><table class="dtTABLE" cellspacing="0"><tr valign="top">
- <th width="33%">Name</th>
- <th width="33%">Default</th>
- <th width="33%">Description</th>
- </tr>
- <tr>
- <td>Connect Timeout<para> -or- </para>Connection Timeout</td>
- <td>15</td>
- <td>The length of time (in seconds) to wait for a connection to the server before
-terminating the attempt and generating an error.</td>
- </tr>
- <tr>
- <td>
- Host<para> -or- </para>Server<para> -or- </para>Data Source<para> -or- </para>
- DataSource<para> -or- </para>Address<para> -or- </para>Addr<para> -or- </para>
- Network Address
- </td>
- <td>localhost</td>
- <td><para>The name or network address of the instance of MySQL to which to connect. Multiple hosts can be
- specified separated by &. This can be useful where multiple MySQL servers are configured for replication
- and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to
- synchronize writes to the database so care should be taken when using this option.
- </para>
- <para>
- In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket.
- Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported.
- </para>
- </td>
- </tr>
- <tr>
- <td>Port</td>
- <td>3306</td>
- <td>The port MySQL is using to listen for connections. Specify -1 for this value to use a
- named pipe connection (Windows only). This value is ignored if Unix socket is used.</td>
- </tr>
- <tr>
- <td>Protocol</td>
- <td>socket</td>
- <td>
- Specifies the type of connection to make to the server.<para>Values can be:</para>
- socket or tcp for a socket connection<br/>
- pipe for a named pipe connection<br/>
- unix for a Unix socket connection<br/>
- memory to use MySQL shared memory
- </td>
- </tr>
- <tr>
- <td>CharSet<para> -or </para>Character Set</td>
- <td></td>
- <td>
- Specifies the character set that should be used to encode all queries sent to the server.
- Resultsets are still returned in the character set of the data returned.
- </td>
- </tr>
- <tr>
- <td>Logging</td>
- <td>false</td>
- <td>When true, various pieces of information is output to any configured TraceListeners.</td>
- </tr>
- <tr>
- <td>Allow Batch</td>
- <td>true</td>
- <td>
- When true, multiple SQL statements can be sent with one command execution.<br/><br/>
- -Note-<br/>
- Starting with MySQL 4.1.1, batch statements should be separated by the server-defined seperator character.<br/>
- Commands sent to earlier versions of MySQL should be seperated with ';'.
- </td>
- </tr>
- <tr>
- <td>Encrypt</td>
- <td>false</td>
- <td>When <B>true</B>, SSL encryption is used for all data sent between the
-client and server if the server has a certificate installed. Recognized values
-are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.<para><b>Note</b> This parameter currently has no
-effect.</para></td>
- </tr>
- <tr>
- <td>Initial Catalog<para> -or- </para>Database</td>
- <td>mysql</td>
- <td>The name of the database to use intially</td>
- </tr>
- <tr>
- <td>Password<para> -or- </para>pwd</td>
- <td></td>
- <td>The password for the MySQL account being used.</td>
- </tr>
- <tr>
- <td>Persist Security Info</td>
- <td>false</td>
- <td>When set to <B>false</B> or <B>no</B> (strongly recommended), security-sensitive
-information, such as the password, is not returned as part of the connection if
-the connection is open or has ever been in an open state. Resetting the
-connection string resets all connection string values including the password.
-Recognized values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.</td>
- </tr>
- <tr>
- <td>User Id<para> -or- </para>Username<para> -or- </para>Uid<para> -or- </para>User name</td>
- <td></td>
- <td>The MySQL login account being used.</td>
- </tr>
- <tr>
- <td>Shared Memory Name</td>
- <td>MYSQL</td>
- <td>The name of the shared memory object to use for communication if the connection protocol is set to memory.</td>
- </tr>
- <tr>
- <td>Allow Zero Datetime</td>
- <td>false</td>
- <td>True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values.
- False will cause a DateTime object to be returned for legal values and an exception will be thrown for illegal values.</td>
- </tr>
- <tr>
- <td>Convert Zero Datetime</td>
- <td>false</td>
- <td>True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime()
- return DateTime.MinValue for date or datetime columns that have illegal values.</td>
- </tr>
- <tr>
- <td>Old Syntax<para> -or- </para>OldSyntax</td>
- <td>false</td>
- <td>
- Allows use of '@' symbol as a parameter marker. See <see cref="MySqlCommand"/> for more
- info.
- <note>This is for compatibility only. All future code should be written to
- use the new '?' parameter marker.</note>
- </td>
- </tr>
- <tr>
- <td>Pipe Name<para> -or- </para>Pipe</td>
- <td>mysql</td>
- <td>When set to the name of a named pipe, the <B>MySqlConnection</B> will attempt to connect to MySQL
- on that named pipe.<br/><br/>This settings only applies to the Windows platform.</td>
- </tr>
- </table>
- </div>
- <para>
- The following table lists the valid names for connection pooling values within
-the <B>ConnectionString</B>. For more information about connection pooling, see
-Connection Pooling for the MySql Data Provider.</para>
- <div class="tablediv"><table class="dtTABLE" cellspacing="0"><tr valign="top">
- <th width="33%">Name</th>
- <th width="33%">Default</th>
- <th width="33%">Description</th>
- </tr>
- <tr>
- <td>Connection Lifetime</td>
- <td>0</td>
- <td>When a connection is returned to the pool, its creation time is compared with
-the current time, and the connection is destroyed if that time span (in seconds)
-exceeds the value specified by <B>Connection Lifetime</B>. This is useful in
-clustered configurations to force load balancing between a running server and a
-server just brought online.
-<para>A value of zero (0) causes pooled connections to have the maximum connection
-timeout.</para></td>
- </tr>
- <tr>
- <td>Max Pool Size</td>
- <td>100</td>
- <td>The maximum number of connections allowed in the pool.</td>
- </tr>
- <tr>
- <td>Min Pool Size</td>
- <td>0</td>
- <td>The minimum number of connections allowed in the pool.</td>
- </tr>
- <tr>
- <td>Pooling</td>
- <td>true</td>
- <td>When <B>true</B>, the <B>MySqlConnection</B> object is drawn from the appropriate
-pool, or if necessary, is created and added to the appropriate pool. Recognized
-values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.</td>
- </tr>
- <tr>
- <td>Reset Pooled Connections<para> -or- </para>
- ResetConnections<para> -or- </para>
- ResetPooledConnections</td>
- <td>true</td>
- <td>Specifies whether a ping and a reset should be sent to the server
- before a pooled connection is returned. Not resetting will yeild faster
- connection opens but also will not clear out session items such as
- temp tables.</td>
- </tr>
- <tr>
- <td>Cache Server Configuration<para> -or- </para>
- CacheServerConfiguration<para> -or- </para>
- CacheServerConfig</td>
- <td>false</td>
- <td>Specifies whether server variables should be updated when a pooled
- connection is returned. Turning this one will yeild faster opens but
- will also not catch any server changes made by other connections.</td>
- </tr>
- </table></div>
-<para>When setting keyword or connection pooling values that require a Boolean
-value, you can use 'yes' instead of 'true', and 'no' instead of 'false'.</para>
-<para><B>Note</B> The MySql Data Provider uses the native socket protocol to
-communicate with MySQL. Therefore, it does not support the use of an ODBC data source name (DSN) when
-connecting to MySQL because it does not add an ODBC layer.</para>
-<para><B>CAUTION</B> In this release, the application should use caution when constructing a
-connection string based on user input (for example when retrieving user ID and password information from a
-dialog box, and appending it to the connection string). The application should
-ensure that a user cannot embed extra connection string parameters in these
-values (for example, entering a password as "validpassword;database=somedb" in
-an attempt to attach to a different database).</para>
- </remarks>
- <example>
- The following example creates a <see cref="MySqlConnection"/> and sets some of its properties
- <code lang="Visual Basic">
- Public Sub CreateConnection()
- Dim myConnection As New MySqlConnection()
- myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"
- myConnection.Open()
- End Sub 'CreateConnection
- </code>
- <code lang="C#">
- public void CreateConnection()
- {
- MySqlConnection myConnection = new MySqlConnection();
- myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass";
- myConnection.Open();
- }
- </code>
-</example>
- <example>
- The following example creates a <see cref="MySqlConnection"/> in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration.
- <code lang="Visual Basic">
- Public Sub CreateConnection()
- Dim myConnection As New MySqlConnection()
- myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"
- myConnection.Open()
- End Sub 'CreateConnection
- </code>
- <code lang="C#">
- public void CreateConnection()
- {
- MySqlConnection myConnection = new MySqlConnection();
- myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass";
- myConnection.Open();
- }
- </code>
- </example>
-</ConnectionString>
+ <para>
+ The <B>StateChange</B> event is not raised unless you explicitly call
+ <B>Close</B> or <B>Dispose</B>.
+ </para>
+ </remarks>
+ <event cref="StateChange">
+ Raised.
+ <data>
+ <para>
+ The event handler receives an argument of type <see cref="System.Data.StateChangeEventArgs"/>
+ containing data related to this event. The following <B>StateChangeEventArgs</B>
+ properties provide information specific to this event.
+ </para>
+ <list type="table">
+ <listheader>
+ <term>Property</term>
+ <description>Description</description>
+ </listheader>
+ <item>
+ <term>
+ <see cref="System.Data.StateChangeEventArgs.CurrentState"/>
+ </term>
+ <description>
+ Gets the new state of the connection. The connection object will
+ be in the new state already when the event is fired.
+ </description>
+ </item>
+ <item>
+ <term>
+ <see cref="System.Data.StateChangeEventArgs.OriginalState"/>
+ </term>
+ <description>Gets the original state of the connection.</description>
+ </item>
+ </list>
+ </data>
+ </event>
+ </StateChange>
+
+ <InfoMessage>
+ <summary>Occurs when MySQL returns warnings as a result of executing a command or query.</summary>
+ <remarks>
+ </remarks>
+ </InfoMessage>
+
+ <ClassSummary>
+ <summary>
+ Represents an open connection to a MySQL Server database. This class cannot be inherited.
+ </summary>
+ <remarks>
+ <para>
+ A <b>MySqlConnection</b> object represents a session to a MySQL Server
+ data source. When you create an instance of <B>MySqlConnection</B>, all
+ properties are set to their initial values. For a list of these values, see the
+ <B>MySqlConnection</B> constructor.
+ </para>
+
+ <para>
+ If the <B>MySqlConnection</B> goes out of scope, it is not closed. Therefore,
+ you must explicitly close the connection by calling <see cref="MySqlConnection.Close"/>
+ or <see cref="MySqlConnection.Dispose"/>.
+ </para>
+ </remarks>
+
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and
+ a <B>MySqlConnection</B>. The <B>MySqlConnection</B> is opened and set as the
+ <see cref="MySqlCommand.Connection"/> for the <B>MySqlCommand</B>. The example then calls
+ <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
+ passed a connection string and a query string that is a SQL INSERT
+ statement.
+ <code lang="Visual Basic">
+ <c>
+ Public Sub InsertRow(myConnectionString As String)
+ ' If the connection string is null, use a default.
+ If myConnectionString = "" Then
+ myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"
+ End If
+ Dim myConnection As New MySqlConnection(myConnectionString)
+ Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"
+ Dim myCommand As New MySqlCommand(myInsertQuery)
+ myCommand.Connection = myConnection
+ myConnection.Open()
+ myCommand.ExecuteNonQuery()
+ myCommand.Connection.Close()
+ End Sub
+ </c>
+ </code>
+ <code lang="C#">
+ <c>
+ public void InsertRow(string myConnectionString)
+ {
+ // If the connection string is null, use a default.
+ if(myConnectionString == "")
+ {
+ myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass";
+ }
+ MySqlConnection myConnection = new MySqlConnection(myConnectionString);
+ string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)";
+ MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
+ myCommand.Connection = myConnection;
+ myConnection.Open();
+ myCommand.ExecuteNonQuery();
+ myCommand.Connection.Close();
+ }
+ </c>
+ </code>
+ </example>
+ </ClassSummary>
+
+ <ConnectionTimeout>
+ <summary>
+ Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
+ </summary>
+ <exception cref="System.ArgumentException">The value set is less than 0.</exception>
+ <remarks>
+ A value of 0 indicates no limit, and should be avoided in a
+ <see cref="MySqlConnection.ConnectionString"/> because an attempt to connect
+ will wait indefinitely.
+ </remarks>
+ <example>
+ The following example creates a MySqlConnection
+ and sets some of its properties in the connection string.
+ <code lang="Visual Basic">
+ Public Sub CreateSqlConnection()
+ Dim myConnection As New MySqlConnection()
+ myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"
+ myConnection.Open()
+ End Sub
+ </code>
+ <code lang="C#">
+ public void CreateSqlConnection()
+ {
+ MySqlConnection myConnection = new MySqlConnection();
+ myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30";
+ myConnection.Open();
+ }
+ </code>
+ </example>
+ </ConnectionTimeout>
+
+
+ <ConnectionString>
+ <summary>
+ Gets or sets the string used to connect to a MySQL Server database.
+ </summary>
+ <remarks>
+ <para>
+ The <B>ConnectionString</B> returned may not be exactly like what was originally
+ set but will be indentical in terms of keyword/value pairs. Security information
+ will not be included unless the Persist Security Info value is set to true.
+ </para>
+ <para>
+ You can use the <B>ConnectionString</B> property to connect to a database.
+ The following example illustrates a typical connection string.
+ </para>
+ <c>"Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass"</c>
+ <para>
+ The <B>ConnectionString</B> property can be set only when the connection is
+ closed. Many of the connection string values have corresponding read-only
+ properties. When the connection string is set, all of these properties are
+ updated, except when an error is detected. In this case, none of the properties
+ are updated. <see cref="MySqlConnection"/> properties return only those settings contained in the
+ <B>ConnectionString</B>.
+ </para>
+ <para>
+ To connect to a local machine, specify "localhost" for the server. If you do not
+ specify a server, localhost is assumed.
+ </para>
+ <para>
+ Resetting the <B>ConnectionString</B> on a closed connection resets all
+ connection string values (and related properties) including the password. For
+ example, if you set a connection string that includes "Database= MyDb", and
+ then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass",
+ the <see cref="MySqlConnection.Database"/> property is no longer set to MyDb.
+ </para>
+ <para>
+ The connection string is parsed immediately after being set. If errors in
+ syntax are found when parsing, a runtime exception, such as <see cref="ArgumentException"/>,
+ is generated. Other errors can be found only when an attempt is made to open the
+ connection.
+ </para>
+ <para>
+ The basic format of a connection string consists of a series of keyword/value
+ pairs separated by semicolons. The equal sign (=) connects each keyword and its
+ value. To include values that contain a semicolon, single-quote character, or
+ double-quote character, the value must be enclosed in double quotes. If the
+ value contains both a semicolon and a double-quote character, the value can be
+ enclosed in single quotes. The single quote is also useful if the value begins
+ with a double-quote character. Conversely, the double quote can be used if the
+ value begins with a single quote. If the value contains both single-quote and
+ double-quote characters, the quote character used to enclose the value must be
+ doubled each time it occurs within the value.
+ </para>
+ <para>
+ To include preceding or trailing spaces in the string value, the value must
+ be enclosed in either single quotes or double quotes. Any leading or trailing
+ spaces around integer, Boolean, or enumerated values are ignored, even if
+ enclosed in quotes. However, spaces within a string literal keyword or value are
+ preserved. Using .NET Framework version 1.1, single or double quotes may be used
+ within a connection string without using delimiters (for example, Data Source=
+ my'Server or Data Source= my"Server), unless a quote character is the first or
+ last character in the value.
+ </para>
+ <para>
+ To include an equal sign (=) in a keyword or value, it must be preceded by
+ another equal sign. For example, in the hypothetical connection string
+ </para>
+ <c>"key==word=value"</c>
+ <para></para>
+ <para>the keyword is "key=word" and the value is "value".</para>
+ <para>
+ If a specific keyword in a keyword= value pair occurs multiple times in a
+ connection string, the last occurrence listed is used in the value set.
+ </para>
+ <para>Keywords are not case sensitive.</para>
+ <para>
+ The following table lists the valid names for keyword values within the
+ <B>ConnectionString</B>.
+ </para>
+
+ <div class="tablediv">
+ <table class="dtTABLE" cellspacing="0">
+ <tr valign="top">
+ <th width="33%">Name</th>
+ <th width="33%">Default</th>
+ <th width="33%">Description</th>
+ </tr>
+ <tr>
+ <td>
+ Connect Timeout<para> -or- </para>Connection Timeout
+ </td>
+ <td>15</td>
+ <td>
+ The length of time (in seconds) to wait for a connection to the server before
+ terminating the attempt and generating an error.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Host<para> -or- </para>Server<para> -or- </para>Data Source<para> -or- </para>
+ DataSource<para> -or- </para>Address<para> -or- </para>Addr<para> -or- </para>
+ Network Address
+ </td>
+ <td>localhost</td>
+ <td>
+ <para>
+ The name or network address of the instance of MySQL to which to connect. Multiple hosts can be
+ specified separated by &. This can be useful where multiple MySQL servers are configured for replication
+ and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to
+ synchronize writes to the database so care should be taken when using this option.
+ </para>
+ <para>
+ In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket.
+ Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported.
+ </para>
+ </td>
+ </tr>
+ <tr>
+ <td>Port</td>
+ <td>3306</td>
+ <td>
+ The port MySQL is using to listen for connections. Specify -1 for this value to use a
+ named pipe connection (Windows only). This value is ignored if Unix socket is used.
+ </td>
+ </tr>
+ <tr>
+ <td>Protocol</td>
+ <td>socket</td>
+ <td>
+ Specifies the type of connection to make to the server.<para>Values can be:</para>
+ socket or tcp for a socket connection<br/>
+ pipe for a named pipe connection<br/>
+ unix for a Unix socket connection<br/>
+ memory to use MySQL shared memory
+ </td>
+ </tr>
+ <tr>
+ <td>
+ CharSet<para> -or </para>Character Set
+ </td>
+ <td></td>
+ <td>
+ Specifies the character set that should be used to encode all queries sent to the server.
+ Resultsets are still returned in the character set of the data returned.
+ </td>
+ </tr>
+ <tr>
+ <td>Logging</td>
+ <td>false</td>
+ <td>When true, various pieces of information is output to any configured TraceListeners.</td>
+ </tr>
+ <tr>
+ <td>Allow Batch</td>
+ <td>true</td>
+ <td>
+ When true, multiple SQL statements can be sent with one command execution.<br/><br/>
+ -Note-<br/>
+ Starting with MySQL 4.1.1, batch statements should be separated by the server-defined seperator character.<br/>
+ Commands sent to earlier versions of MySQL should be seperated with ';'.
+ </td>
+ </tr>
+ <tr>
+ <td>Encrypt</td>
+ <td>false</td>
+ <td>
+ When <B>true</B>, SSL encryption is used for all data sent between the
+ client and server if the server has a certificate installed. Recognized values
+ are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.<para>
+ <b>Note</b> This parameter currently has no
+ effect.
+ </para>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Initial Catalog<para> -or- </para>Database
+ </td>
+ <td>mysql</td>
+ <td>The name of the database to use intially</td>
+ </tr>
+ <tr>
+ <td>
+ Password<para> -or- </para>pwd
+ </td>
+ <td></td>
+ <td>The password for the MySQL account being used.</td>
+ </tr>
+ <tr>
+ <td>Persist Security Info</td>
+ <td>false</td>
+ <td>
+ When set to <B>false</B> or <B>no</B> (strongly recommended), security-sensitive
+ information, such as the password, is not returned as part of the connection if
+ the connection is open or has ever been in an open state. Resetting the
+ connection string resets all connection string values including the password.
+ Recognized values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ User Id<para> -or- </para>Username<para> -or- </para>Uid<para> -or- </para>User name
+ </td>
+ <td></td>
+ <td>The MySQL login account being used.</td>
+ </tr>
+ <tr>
+ <td>Shared Memory Name</td>
+ <td>MYSQL</td>
+ <td>The name of the shared memory object to use for communication if the connection protocol is set to memory.</td>
+ </tr>
+ <tr>
+ <td>Allow Zero Datetime</td>
+ <td>false</td>
+ <td>
+ True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values.
+ False will cause a DateTime object to be returned for legal values and an exception will be thrown for illegal values.
+ </td>
+ </tr>
+ <tr>
+ <td>Convert Zero Datetime</td>
+ <td>false</td>
+ <td>
+ True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime()
+ return DateTime.MinValue for date or datetime columns that have illegal values.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Old Syntax<para> -or- </para>OldSyntax
+ </td>
+ <td>false</td>
+ <td>
+ Allows use of '@' symbol as a parameter marker. See <see cref="MySqlCommand"/> for more
+ info.
+ <note>
+ This is for compatibility only. All future code should be written to
+ use the new '?' parameter marker.
+ </note>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Pipe Name<para> -or- </para>Pipe
+ </td>
+ <td>mysql</td>
+ <td>
+ When set to the name of a named pipe, the <B>MySqlConnection</B> will attempt to connect to MySQL
+ on that named pipe.<br/><br/>This settings only applies to the Windows platform.
+ </td>
+ </tr>
+ </table>
+ </div>
+ <para>
+ The following table lists the valid names for connection pooling values within
+ the <B>ConnectionString</B>. For more information about connection pooling, see
+ Connection Pooling for the MySql Data Provider.
+ </para>
+ <div class="tablediv">
+ <table class="dtTABLE" cellspacing="0">
+ <tr valign="top">
+ <th width="33%">Name</th>
+ <th width="33%">Default</th>
+ <th width="33%">Description</th>
+ </tr>
+ <tr>
+ <td>Connection Lifetime</td>
+ <td>0</td>
+ <td>
+ When a connection is returned to the pool, its creation time is compared with
+ the current time, and the connection is destroyed if that time span (in seconds)
+ exceeds the value specified by <B>Connection Lifetime</B>. This is useful in
+ clustered configurations to force load balancing between a running server and a
+ server just brought online.
+ <para>
+ A value of zero (0) causes pooled connections to have the maximum connection
+ timeout.
+ </para>
+ </td>
+ </tr>
+ <tr>
+ <td>Max Pool Size</td>
+ <td>100</td>
+ <td>The maximum number of connections allowed in the pool.</td>
+ </tr>
+ <tr>
+ <td>Min Pool Size</td>
+ <td>0</td>
+ <td>The minimum number of connections allowed in the pool.</td>
+ </tr>
+ <tr>
+ <td>Pooling</td>
+ <td>true</td>
+ <td>
+ When <B>true</B>, the <B>MySqlConnection</B> object is drawn from the appropriate
+ pool, or if necessary, is created and added to the appropriate pool. Recognized
+ values are <B>true</B>, <B>false</B>, <B>yes</B>, and <B>no</B>.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Reset Pooled Connections<para> -or- </para>
+ ResetConnections<para> -or- </para>
+ ResetPooledConnections
+ </td>
+ <td>true</td>
+ <td>
+ Specifies whether a ping and a reset should be sent to the server
+ before a pooled connection is returned. Not resetting will yeild faster
+ connection opens but also will not clear out session items such as
+ temp tables.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Cache Server Configuration<para> -or- </para>
+ CacheServerConfiguration<para> -or- </para>
+ CacheServerConfig
+ </td>
+ <td>false</td>
+ <td>
+ Specifies whether server variables should be updated when a pooled
+ connection is returned. Turning this one will yeild faster opens but
+ will also not catch any server changes made by other connections.
+ </td>
+ </tr>
+ </table>
+ </div>
+ <para>
+ When setting keyword or connection pooling values that require a Boolean
+ value, you can use 'yes' instead of 'true', and 'no' instead of 'false'.
+ </para>
+ <para>
+ <B>Note</B> The MySql Data Provider uses the native socket protocol to
+ communicate with MySQL. Therefore, it does not support the use of an ODBC data source name (DSN) when
+ connecting to MySQL because it does not add an ODBC layer.
+ </para>
+ <para>
+ <B>CAUTION</B> In this release, the application should use caution when constructing a
+ connection string based on user input (for example when retrieving user ID and password information from a
+ dialog box, and appending it to the connection string). The application should
+ ensure that a user cannot embed extra connection string parameters in these
+ values (for example, entering a password as "validpassword;database=somedb" in
+ an attempt to attach to a different database).
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> and sets some of its properties
+ <code lang="Visual Basic">
+ Public Sub CreateConnection()
+ Dim myConnection As New MySqlConnection()
+ myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"
+ myConnection.Open()
+ End Sub 'CreateConnection
+ </code>
+ <code lang="C#">
+ public void CreateConnection()
+ {
+ MySqlConnection myConnection = new MySqlConnection();
+ myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass";
+ myConnection.Open();
+ }
+ </code>
+ </example>
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration.
+ <code lang="Visual Basic">
+ Public Sub CreateConnection()
+ Dim myConnection As New MySqlConnection()
+ myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"
+ myConnection.Open()
+ End Sub 'CreateConnection
+ </code>
+ <code lang="C#">
+ public void CreateConnection()
+ {
+ MySqlConnection myConnection = new MySqlConnection();
+ myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass";
+ myConnection.Open();
+ }
+ </code>
+ </example>
+ </ConnectionString>
</docs>
Modified: branches/1.0/mysqlclient/docs/MySqlDataAdapter.xml
===================================================================
--- branches/1.0/mysqlclient/docs/MySqlDataAdapter.xml 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/docs/MySqlDataAdapter.xml 2006-10-18 21:25:06 UTC (rev 415)
@@ -1,723 +1,803 @@
-<docs>
-<class>
- <summary>
- Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited.
- </summary>
-<remarks>
- <para>
- The <B>MySQLDataAdapter</B>, serves as a bridge between a <see cref="System.Data.DataSet"/>
- and MySQL for retrieving and saving data. The <B>MySQLDataAdapter</B> provides this
- bridge by mapping <see cref="DbDataAdapter.Fill"/>, which changes the data in the
- <B>DataSet</B> to match the data in the data source, and <see cref="DbDataAdapter.Update"/>,
- which changes the data in the data source to match the data in the <B>DataSet</B>,
- using the appropriate SQL statements against the data source.
- </para>
- <para>
- When the <B>MySQLDataAdapter</B> fills a <B>DataSet</B>, it will create the necessary
- tables and columns for the returned data if they do not already exist. However, primary
- key information will not be included in the implicitly created schema unless the
- <see cref="System.Data.MissingSchemaAction"/> property is set to <see cref="System.Data.MissingSchemaAction.AddWithKey"/>.
- You may also have the <B>MySQLDataAdapter</B> create the schema of the <B>DataSet</B>,
- including primary key information, before filling it with data using <see cref="System.Data.Common.DbDataAdapter.FillSchema"/>.
- </para>
- <para><B>MySQLDataAdapter</B> is used in conjunction with <see cref="MySqlConnection"/>
- and <see cref="MySqlCommand"/> to increase performance when connecting to a MySQL database.
- </para>
- <para>The <B>MySQLDataAdapter</B> also includes the <see cref="MySqlDataAdapter.SelectCommand"/>,
- <see cref="MySqlDataAdapter.InsertCommand"/>, <see cref="MySqlDataAdapter.DeleteCommand"/>,
- <see cref="MySqlDataAdapter.UpdateCommand"/>, and <see cref="DataAdapter.TableMappings"/>
- properties to facilitate the loading and updating of data.
- </para>
- <para>When an instance of <B>MySQLDataAdapter</B> is created, the read/write properties
- are set to initial values. For a list of these values, see the <B>MySQLDataAdapter</B>
- constructor.
- </para>
- <note>
- Please be aware that the <see cref="DataColumn"/> class in .NET 1.0 and 1.1 does not allow columns
- with type of UInt16, UInt32, or UInt64 to be autoincrement columns. If you plan to use autoincremement
- columns with MySQL, you should consider using signed integer columns.
- </note>
-</remarks>
-
-<example>
- The following example creates a <see cref="MySqlCommand"/> and a <see cref="MySqlConnection"/>.
- The <B>MySqlConnection</B> is opened and set as the <see cref="MySqlCommand.Connection"/> for the
- <B>MySqlCommand</B>. The example then calls <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes
- the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
- passed a connection string and a query string that is a SQL INSERT
- statement.
- <code lang="Visual Basic">
-Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet
- Dim conn As New MySqlConnection(connection)
- Dim adapter As New MySqlDataAdapter()
- adapter.SelectCommand = new MySqlCommand(query, conn)
- adapter.Fill(dataset)
- Return dataset
-End Function
- </code>
- <code lang="C#">
-public DataSet SelectRows(DataSet dataset,string connection,string query)
-{
- MySqlConnection conn = new MySqlConnection(connection);
- MySqlDataAdapter adapter = new MySqlDataAdapter();
- adapter.SelectCommand = new MySqlCommand(query, conn);
- adapter.Fill(dataset);
- return dataset;
-}
- </code>
-</example>
-</class>
-
-<Ctor>
- <overloads></overloads>
- <summary>
- Initializes a new instance of the MySqlDataAdapter class.
- </summary>
- <remarks>
- <para>
- When an instance of <see cref="MySqlDataAdapter"/> is created,
- the following read/write properties are set to the following initial
- values.
- </para>
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="MissingMappingAction"/></term><term><B>MissingMappingAction.Passthrough</B></term></item>
- <item><term><see cref="MissingSchemaAction"/></term><term><B>MissingSchemaAction.Add</B></term></item>
- </list>
- <para>
- You can change the value of any of these properties through a separate call
- to the property.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
-its properties.
-<code lang="Visual Basic">
-Public Sub CreateSqlDataAdapter()
- Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _
- "database=test")
- Dim da As MySqlDataAdapter = New MySqlDataAdapter
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey
-
- da.SelectCommand = New MySqlCommand("SELECT id, name FROM mytable", conn)
- da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
- "VALUES (?id, ?name)", conn)
- da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
- "WHERE id=?oldId", conn)
- da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
+<?xml version="1.0" encoding="Windows-1252"?>
+<docs>
+ <class>
+ <summary>
+ Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited.
+ </summary>
+ <remarks>
+ <para>
+ The <B>MySQLDataAdapter</B>, serves as a bridge between a <see cref="System.Data.DataSet"/>
+ and MySQL for retrieving and saving data. The <B>MySQLDataAdapter</B> provides this
+ bridge by mapping <see cref="DbDataAdapter.Fill(System.Data.DataSet)"/>, which changes the data in the
+ <B>DataSet</B> to match the data in the data source, and
+ <see cref="DbDataAdapter.Update(System.Data.DataSet)"/>,
+ which changes the data in the data source to match the data in the <B>DataSet</B>,
+ using the appropriate SQL statements against the data source.
+ </para>
+ <para>
+ When the <B>MySQLDataAdapter</B> fills a <B>DataSet</B>, it will create the necessary
+ tables and columns for the returned data if they do not already exist. However, primary
+ key information will not be included in the implicitly created schema unless the
+ <see cref="System.Data.MissingSchemaAction"/> property is set to <see cref="System.Data.MissingSchemaAction.AddWithKey"/>.
+ You may also have the <B>MySQLDataAdapter</B> create the schema of the <B>DataSet</B>,
+ including primary key information, before filling it with data using
+ <see cref="System.Data.Common.DbDataAdapter.FillSchema(System.Data.DataTable, System.Data.SchemaType)"/>.
+ </para>
+ <para>
+ <B>MySQLDataAdapter</B> is used in conjunction with <see cref="MySqlConnection"/>
+ and <see cref="MySqlCommand"/> to increase performance when connecting to a MySQL database.
+ </para>
+ <para>
+ The <B>MySQLDataAdapter</B> also includes the <see cref="MySqlDataAdapter.SelectCommand"/>,
+ <see cref="MySqlDataAdapter.InsertCommand"/>, <see cref="MySqlDataAdapter.DeleteCommand"/>,
+ <see cref="MySqlDataAdapter.UpdateCommand"/>, and <see cref="DataAdapter.TableMappings"/>
+ properties to facilitate the loading and updating of data.
+ </para>
+ <para>
+ When an instance of <B>MySQLDataAdapter</B> is created, the read/write properties
+ are set to initial values. For a list of these values, see the <B>MySQLDataAdapter</B>
+ constructor.
+ </para>
+ <note>
+ Please be aware that the <see cref="DataColumn"/> class in .NET 1.0 and 1.1 does not allow columns
+ with type of UInt16, UInt32, or UInt64 to be autoincrement columns. If you plan to use autoincremement
+ columns with MySQL, you should consider using signed integer columns.
+ </note>
+ </remarks>
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ <example>
+ The following example creates a <see cref="MySqlCommand"/> and a <see cref="MySqlConnection"/>.
+ The <B>MySqlConnection</B> is opened and set as the <see cref="MySqlCommand.Connection"/> for the
+ <B>MySqlCommand</B>. The example then calls <see cref="MySqlCommand.ExecuteNonQuery"/>, and closes
+ the connection. To accomplish this, the <B>ExecuteNonQuery</B> is
+ passed a connection string and a query string that is a SQL INSERT
+ statement.
+ <code lang="Visual Basic">
+ Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet
+ Dim conn As New MySqlConnection(connection)
+ Dim adapter As New MySqlDataAdapter()
+ adapter.SelectCommand = new MySqlCommand(query, conn)
+ adapter.Fill(dataset)
+ Return dataset
+ End Function
+ </code>
+ <code lang="C#">
+ public DataSet SelectRows(DataSet dataset,string connection,string query)
+ {
+ MySqlConnection conn = new MySqlConnection(connection);
+ MySqlDataAdapter adapter = new MySqlDataAdapter();
+ adapter.SelectCommand = new MySqlCommand(query, conn);
+ adapter.Fill(dataset);
+ return dataset;
+ }
+ </code>
+ </example>
+ </class>
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
-End Sub
-</code>
-<code lang="C#">
-public static void CreateSqlDataAdapter()
-{
- MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test");
- MySqlDataAdapter da = new MySqlDataAdapter();
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-
- da.SelectCommand = new MySqlCommand("SELECT id, name FROM mytable", conn);
- da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
- "VALUES (?id, ?name)", conn);
- da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
- "WHERE id=?oldId", conn);
- da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
+ <Ctor>
+ <overloads></overloads>
+ <summary>
+ Initializes a new instance of the MySqlDataAdapter class.
+ </summary>
+ <remarks>
+ <para>
+ When an instance of <see cref="MySqlDataAdapter"/> is created,
+ the following read/write properties are set to the following initial
+ values.
+ </para>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="MissingMappingAction"/>
+ </term>
+ <term>
+ <B>MissingMappingAction.Passthrough</B>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="MissingSchemaAction"/>
+ </term>
+ <term>
+ <B>MissingSchemaAction.Add</B>
+ </term>
+ </item>
+ </list>
+ <para>
+ You can change the value of any of these properties through a separate call
+ to the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
+ its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateSqlDataAdapter()
+ Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _
+ "database=test")
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ da.SelectCommand = New MySqlCommand("SELECT id, name FROM mytable", conn)
+ da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
+ "VALUES (?id, ?name)", conn)
+ da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
+ "WHERE id=?oldId", conn)
+ da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
-}
-</code>
- </example>
-</Ctor>
-
-<Ctor1>
- <summary>
- Initializes a new instance of the <see cref="MySqlDataAdapter"/> class with
- the specified <see cref="MySqlCommand"/> as the <see cref="SelectCommand"/>
- property.
- </summary>
- <param name="selectCommand">
- <see cref="MySqlCommand"/> that is a SQL SELECT statement or stored procedure and is set
- as the <see cref="SelectCommand"/> property of the <see cref="MySqlDataAdapter"/>.
- </param>
- <remarks>
- <para>
- When an instance of <see cref="MySqlDataAdapter"/> is created,
- the following read/write properties are set to the following initial
- values.
- </para>
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="MissingMappingAction"/></term><term><B>MissingMappingAction.Passthrough</B></term></item>
- <item><term><see cref="MissingSchemaAction"/></term><term><B>MissingSchemaAction.Add</B></term></item>
- </list>
- <para>
- You can change the value of any of these properties through a separate call
- to the property.
- </para>
- <para>
- When <B>SelectCommand</B> (or any of the other command properties) is assigned
- to a previously created <see cref="MySqlCommand"/>, the <B>MySqlCommand</B> is not cloned.
- The <B>SelectCommand</B> maintains a reference to the previously created <B>MySqlCommand</B>
- object.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
-its properties.
-<code lang="Visual Basic">
-Public Sub CreateSqlDataAdapter()
- Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _
- "database=test")
- Dim cmd as new MySqlCommand("SELECT id, name FROM mytable", conn)
- Dim da As MySqlDataAdapter = New MySqlDataAdapter(cmd)
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey
-
- da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
- "VALUES (?id, ?name)", conn)
- da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
- "WHERE id=?oldId", conn)
- da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
-End Sub
-</code>
-<code lang="C#">
-public static void CreateSqlDataAdapter()
-{
- MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test");
- MySqlCommand cmd = new MySqlCommand("SELECT id, name FROM mytable", conn);
- MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-
- da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
- "VALUES (?id, ?name)", conn);
- da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
- "WHERE id=?oldId", conn);
- da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ End Sub
+ </code>
+ <code lang="C#">
+ public static void CreateSqlDataAdapter()
+ {
+ MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test");
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ da.SelectCommand = new MySqlCommand("SELECT id, name FROM mytable", conn);
+ da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
+ "VALUES (?id, ?name)", conn);
+ da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
+ "WHERE id=?oldId", conn);
+ da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
-}
-</code>
- </example>
-</Ctor1>
-
-<Ctor2>
- <summary>
- Initializes a new instance of the <see cref="MySqlDataAdapter"/> class with
- a <see cref="SelectCommand"/> and a <see cref="MySqlConnection"/> object.
- </summary>
- <param name="selectCommandText">
- A <b>String</b> that is a SQL SELECT statement or stored procedure to be used by
- the <see cref="SelectCommand"/> property of the <see cref="MySqlDataAdapter"/>.
- </param>
- <param name="connection">A <see cref="MySqlConnection"/> that represents the connection.</param>
- <remarks>
- <para>
- This implementation of the <see cref="MySqlDataAdapter"/> opens and closes a <see cref="MySqlConnection"/>
- if it is not already open. This can be useful in a an application that must call the
- <see cref="DbDataAdapter.Fill"/> method for two or more <B>MySqlDataAdapter</B> objects.
- If the <B>MySqlConnection</B> is already open, you must explicitly call
- <see cref="MySqlConnection.Close"/> or <see cref="MySqlConnection.Dispose"/> to close it.
- </para>
- <para>
- When an instance of <see cref="MySqlDataAdapter"/> is created,
- the following read/write properties are set to the following initial
- values.
- </para>
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="MissingMappingAction"/></term><term><B>MissingMappingAction.Passthrough</B></term></item>
- <item><term><see cref="MissingSchemaAction"/></term><term><B>MissingSchemaAction.Add</B></term></item>
- </list>
- <para>
- You can change the value of any of these properties through a separate call
- to the property.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
-its properties.
-<code lang="Visual Basic">
-Public Sub CreateSqlDataAdapter()
- Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _
- "database=test")
- Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", conn)
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey
-
- da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
- "VALUES (?id, ?name)", conn)
- da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
- "WHERE id=?oldId", conn)
- da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
-End Sub
-</code>
-<code lang="C#">
-public static void CreateSqlDataAdapter()
-{
- MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test");
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", conn);
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-
- da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
- "VALUES (?id, ?name)", conn);
- da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
- "WHERE id=?oldId", conn);
- da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ }
+ </code>
+ </example>
+ </Ctor>
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ <Ctor1>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlDataAdapter"/> class with
+ the specified <see cref="MySqlCommand"/> as the <see cref="SelectCommand"/>
+ property.
+ </summary>
+ <param name="selectCommand">
+ <see cref="MySqlCommand"/> that is a SQL SELECT statement or stored procedure and is set
+ as the <see cref="SelectCommand"/> property of the <see cref="MySqlDataAdapter"/>.
+ </param>
+ <remarks>
+ <para>
+ When an instance of <see cref="MySqlDataAdapter"/> is created,
+ the following read/write properties are set to the following initial
+ values.
+ </para>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="MissingMappingAction"/>
+ </term>
+ <term>
+ <B>MissingMappingAction.Passthrough</B>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="MissingSchemaAction"/>
+ </term>
+ <term>
+ <B>MissingSchemaAction.Add</B>
+ </term>
+ </item>
+ </list>
+ <para>
+ You can change the value of any of these properties through a separate call
+ to the property.
+ </para>
+ <para>
+ When <B>SelectCommand</B> (or any of the other command properties) is assigned
+ to a previously created <see cref="MySqlCommand"/>, the <B>MySqlCommand</B> is not cloned.
+ The <B>SelectCommand</B> maintains a reference to the previously created <B>MySqlCommand</B>
+ object.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
+ its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateSqlDataAdapter()
+ Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _
+ "database=test")
+ Dim cmd as new MySqlCommand("SELECT id, name FROM mytable", conn)
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter(cmd)
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
-}
-</code>
- </example>
-</Ctor2>
-
-<Ctor3>
- <summary>
- Initializes a new instance of the <see cref="MySqlDataAdapter"/> class with
- a <see cref="SelectCommand"/> and a connection string.
- </summary>
- <param name="selectCommandText">
- A <see cref="string"/> that is a SQL SELECT statement or stored procedure to
- be used by the <see cref="SelectCommand"/> property of the <see cref="MySqlDataAdapter"/>.
- </param>
- <param name="selectConnString">The connection string</param>
- <remarks>
- <para>
- When an instance of <see cref="MySqlDataAdapter"/> is created,
- the following read/write properties are set to the following initial
- values.
- </para>
- <list type="table">
- <listheader><term>Properties</term><term>Initial Value</term></listheader>
- <item><term><see cref="MissingMappingAction"/></term><term><B>MissingMappingAction.Passthrough</B></term></item>
- <item><term><see cref="MissingSchemaAction"/></term><term><B>MissingSchemaAction.Add</B></term></item>
- </list>
- <para>
- You can change the value of any of these properties through a separate call
- to the property.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
-its properties.
-<code lang="Visual Basic">
-Public Sub CreateSqlDataAdapter()
- Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test")
- Dim conn As MySqlConnection = da.SelectCommand.Connection
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey
-
- da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
- "VALUES (?id, ?name)", conn)
- da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
- "WHERE id=?oldId", conn)
- da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
+ da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
+ "VALUES (?id, ?name)", conn)
+ da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
+ "WHERE id=?oldId", conn)
+ da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
-End Sub
-</code>
-<code lang="C#">
-public static void CreateSqlDataAdapter()
-{
- MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test");
- MySqlConnection conn = da.SelectCommand.Connection;
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-
- da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
- "VALUES (?id, ?name)", conn);
- da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
- "WHERE id=?oldId", conn);
- da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
- da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
-
- da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ End Sub
+ </code>
+ <code lang="C#">
+ public static void CreateSqlDataAdapter()
+ {
+ MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test");
+ MySqlCommand cmd = new MySqlCommand("SELECT id, name FROM mytable", conn);
+ MySqlDataAdapter da = new MySqlDataAdapter(cmd);
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
-}
-</code>
- </example>
-</Ctor3>
-
-<DeleteCommand>
- <summary>
- Gets or sets a SQL statement or stored procedure used to delete records from the data set.
- </summary>
- <value>
- A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DataAdapter.Update"/> to delete records in the
- database that correspond to deleted rows in the <see cref="DataSet"/>.
- </value>
- <remarks>
- <para>During <see cref="System.Data.Common.DataAdapter.Update"/>, if this property is not set and primary key information
- is present in the <see cref="DataSet"/>, the <B>DeleteCommand</B> can be generated
- automatically if you set the <see cref="SelectCommand"/> property and use the
- <see cref="MySqlCommandBuilder"/>. Then, any additional commands that you do not set are
- generated by the <B>MySqlCommandBuilder</B>. This generation logic requires key column
- information to be present in the <B>DataSet</B>.
- </para>
- <para>
- When <B>DeleteCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
- the <B>MySqlCommand</B> is not cloned. The <B>DeleteCommand</B> maintains a reference
- to the previously created <B>MySqlCommand</B> object.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets the
-<see cref="SelectCommand"/> and <B>DeleteCommand</B> properties. It assumes you have already
-created a <see cref="MySqlConnection"/> object.
-<code lang="Visual Basic">
-Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
-
- Dim da As MySqlDataAdapter = New MySqlDataAdapter()
- Dim cmd As MySqlCommand
- Dim parm As MySqlParameter
+ da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
+ "VALUES (?id, ?name)", conn);
+ da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
+ "WHERE id=?oldId", conn);
+ da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
- ' Create the SelectCommand.
- cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
- da.SelectCommand = cmd
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ }
+ </code>
+ </example>
+ </Ctor1>
- ' Create the DeleteCommand.
- cmd = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
+ <Ctor2>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlDataAdapter"/> class with
+ a <see cref="SelectCommand"/> and a <see cref="MySqlConnection"/> object.
+ </summary>
+ <param name="selectCommandText">
+ A <b>String</b> that is a SQL SELECT statement or stored procedure to be used by
+ the <see cref="SelectCommand"/> property of the <see cref="MySqlDataAdapter"/>.
+ </param>
+ <param name="connection">
+ A <see cref="MySqlConnection"/> that represents the connection.
+ </param>
+ <remarks>
+ <para>
+ This implementation of the <see cref="MySqlDataAdapter"/> opens and closes a <see cref="MySqlConnection"/>
+ if it is not already open. This can be useful in a an application that must call the
+ <see cref="DbDataAdapter.Fill(System.Data.DataSet)"/> method for two or more <B>MySqlDataAdapter</B> objects.
+ If the <B>MySqlConnection</B> is already open, you must explicitly call
+ <see cref="MySqlConnection.Close"/> or <see cref="MySqlConnection.Dispose"/> to close it.
+ </para>
+ <para>
+ When an instance of <see cref="MySqlDataAdapter"/> is created,
+ the following read/write properties are set to the following initial
+ values.
+ </para>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="MissingMappingAction"/>
+ </term>
+ <term>
+ <B>MissingMappingAction.Passthrough</B>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="MissingSchemaAction"/>
+ </term>
+ <term>
+ <B>MissingSchemaAction.Add</B>
+ </term>
+ </item>
+ </list>
+ <para>
+ You can change the value of any of these properties through a separate call
+ to the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
+ its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateSqlDataAdapter()
+ Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _
+ "database=test")
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", conn)
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey
- parm = cmd.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
- parm.SourceVersion = DataRowVersion.Original
+ da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
+ "VALUES (?id, ?name)", conn)
+ da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
+ "WHERE id=?oldId", conn)
+ da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
- da.DeleteCommand = cmd
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- Return da
-End Function
-</code>
-<code lang="C#">
-public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
-{
- MySqlDataAdapter da = new MySqlDataAdapter();
- MySqlCommand cmd;
- MySqlParameter parm;
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
- // Create the SelectCommand.
- cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ End Sub
+ </code>
+ <code lang="C#">
+ public static void CreateSqlDataAdapter()
+ {
+ MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test");
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", conn);
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+ da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
+ "VALUES (?id, ?name)", conn);
+ da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
+ "WHERE id=?oldId", conn);
+ da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
- da.SelectCommand = cmd;
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- // Create the DeleteCommand.
- cmd = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
- parm = cmd.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
- parm.SourceVersion = DataRowVersion.Original;
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ }
+ </code>
+ </example>
+ </Ctor2>
- da.DeleteCommand = cmd;
+ <Ctor3>
+ <summary>
+ Initializes a new instance of the <see cref="MySqlDataAdapter"/> class with
+ a <see cref="SelectCommand"/> and a connection string.
+ </summary>
+ <param name="selectCommandText">
+ A <see cref="string"/> that is a SQL SELECT statement or stored procedure to
+ be used by the <see cref="SelectCommand"/> property of the <see cref="MySqlDataAdapter"/>.
+ </param>
+ <param name="selectConnString">The connection string</param>
+ <remarks>
+ <para>
+ When an instance of <see cref="MySqlDataAdapter"/> is created,
+ the following read/write properties are set to the following initial
+ values.
+ </para>
+ <list type="table">
+ <listheader>
+ <term>Properties</term>
+ <term>Initial Value</term>
+ </listheader>
+ <item>
+ <term>
+ <see cref="MissingMappingAction"/>
+ </term>
+ <term>
+ <B>MissingMappingAction.Passthrough</B>
+ </term>
+ </item>
+ <item>
+ <term>
+ <see cref="MissingSchemaAction"/>
+ </term>
+ <term>
+ <B>MissingSchemaAction.Add</B>
+ </term>
+ </item>
+ </list>
+ <para>
+ You can change the value of any of these properties through a separate call
+ to the property.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets some of
+ its properties.
+ <code lang="Visual Basic">
+ Public Sub CreateSqlDataAdapter()
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test")
+ Dim conn As MySqlConnection = da.SelectCommand.Connection
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey
- return da;
-}
-</code>
- </example>
-</DeleteCommand>
-
-<InsertCommand>
- <summary>
- Gets or sets a SQL statement or stored procedure used to insert records into the data set.
- </summary>
- <value>
- A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DataAdapter.Update"/> to insert records into the
- database that correspond to new rows in the <see cref="DataSet"/>.
- </value>
- <remarks>
- <para>During <see cref="System.Data.Common.DataAdapter.Update"/>, if this property is not set and primary key information
- is present in the <see cref="DataSet"/>, the <B>InsertCommand</B> can be generated
- automatically if you set the <see cref="SelectCommand"/> property and use the
- <see cref="MySqlCommandBuilder"/>. Then, any additional commands that you do not set are
- generated by the <B>MySqlCommandBuilder</B>. This generation logic requires key column
- information to be present in the <B>DataSet</B>.
- </para>
- <para>
- When <B>InsertCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
- the <B>MySqlCommand</B> is not cloned. The <B>InsertCommand</B> maintains a reference
- to the previously created <B>MySqlCommand</B> object.
- </para>
- <note>
- If execution of this command returns rows, these rows may be added to the <B>DataSet</B>
- depending on how you set the <see cref="MySqlCommand.UpdatedRowSource"/> property of the <B>MySqlCommand</B> object.
- </note>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets the
-<see cref="SelectCommand"/> and <B>InsertCommand</B> properties. It assumes you have already
-created a <see cref="MySqlConnection"/> object.
-<code lang="Visual Basic">
-Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
-
- Dim da As MySqlDataAdapter = New MySqlDataAdapter()
- Dim cmd As MySqlCommand
- Dim parm As MySqlParameter
+ da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _
+ "VALUES (?id, ?name)", conn)
+ da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=?id, name=?name " & _
+ "WHERE id=?oldId", conn)
+ da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
- ' Create the SelectCommand.
- cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name")
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
- da.SelectCommand = cmd
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original
+ End Sub
+ </code>
+ <code lang="C#">
+ public static void CreateSqlDataAdapter()
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test");
+ MySqlConnection conn = da.SelectCommand.Connection;
+ da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- ' Create the InsertCommand.
- cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id, ?name)", conn)
+ da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " +
+ "VALUES (?id, ?name)", conn);
+ da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=?id, name=?name " +
+ "WHERE id=?oldId", conn);
+ da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
- cmd.Parameters.Add( "?id", MySqlDbType.VarChar, 15, "id" )
- cmd.Parameters.Add( "?name", MySqlDbType.VarChar, 15, "name" )
- da.InsertCommand = cmd
-
- Return da
-End Function
-</code>
-<code lang="C#">
-public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
-{
- MySqlDataAdapter da = new MySqlDataAdapter();
- MySqlCommand cmd;
- MySqlParameter parm;
+ da.InsertCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.InsertCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
- // Create the SelectCommand.
- cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+ da.UpdateCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ da.UpdateCommand.Parameters.Add("?name", MySqlDbType.VarChar, 40, "name");
+ da.UpdateCommand.Parameters.Add("?oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+ da.DeleteCommand.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original;
+ }
+ </code>
+ </example>
+ </Ctor3>
- da.SelectCommand = cmd;
+ <DeleteCommand>
+ <summary>
+ Gets or sets a SQL statement or stored procedure used to delete records from the data set.
+ </summary>
+ <value>
+ A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DataAdapter.Update"/> to delete records in the
+ database that correspond to deleted rows in the <see cref="DataSet"/>.
+ </value>
+ <remarks>
+ <para>
+ During <see cref="System.Data.Common.DataAdapter.Update"/>, if this property is not set and primary key information
+ is present in the <see cref="DataSet"/>, the <B>DeleteCommand</B> can be generated
+ automatically if you set the <see cref="SelectCommand"/> property and use the
+ <see cref="MySqlCommandBuilder"/>. Then, any additional commands that you do not set are
+ generated by the <B>MySqlCommandBuilder</B>. This generation logic requires key column
+ information to be present in the <B>DataSet</B>.
+ </para>
+ <para>
+ When <B>DeleteCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
+ the <B>MySqlCommand</B> is not cloned. The <B>DeleteCommand</B> maintains a reference
+ to the previously created <B>MySqlCommand</B> object.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets the
+ <see cref="SelectCommand"/> and <B>DeleteCommand</B> properties. It assumes you have already
+ created a <see cref="MySqlConnection"/> object.
+ <code lang="Visual Basic">
+ Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
- // Create the InsertCommand.
- cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id,?name)", conn);
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15, "id" );
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15, "name" );
-
- da.InsertCommand = cmd;
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter()
+ Dim cmd As MySqlCommand
+ Dim parm As MySqlParameter
- return da;
-}
-</code>
- </example>
-</InsertCommand>
-
-<UpdateCommand>
- <summary>
- Gets or sets a SQL statement or stored procedure used to updated records in the data source.
- </summary>
- <value>
- A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DataAdapter.Update"/> to update records in the
- database with data from the <see cref="DataSet"/>.
- </value>
- <remarks>
- <para>During <see cref="System.Data.Common.DataAdapter.Update"/>, if this property is not set and primary key information
- is present in the <see cref="DataSet"/>, the <B>UpdateCommand</B> can be generated
- automatically if you set the <see cref="SelectCommand"/> property and use the
- <see cref="MySqlCommandBuilder"/>. Then, any additional commands that you do not set are
- generated by the <B>MySqlCommandBuilder</B>. This generation logic requires key column
- information to be present in the <B>DataSet</B>.
- </para>
- <para>
- When <B>UpdateCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
- the <B>MySqlCommand</B> is not cloned. The <B>UpdateCommand</B> maintains a reference
- to the previously created <B>MySqlCommand</B> object.
- </para>
- <note>
- If execution of this command returns rows, these rows may be merged with the DataSet
- depending on how you set the <see cref="MySqlCommand.UpdatedRowSource"/> property of the <B>MySqlCommand</B> object.
- </note>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets the
-<see cref="SelectCommand"/> and <B>UpdateCommand</B> properties. It assumes you have already
-created a <see cref="MySqlConnection"/> object.
-<code lang="Visual Basic">
-Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
-
- Dim da As MySqlDataAdapter = New MySqlDataAdapter()
- Dim cmd As MySqlCommand
- Dim parm As MySqlParameter
+ ' Create the SelectCommand.
+ cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
- ' Create the SelectCommand.
- cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
+ da.SelectCommand = cmd
- da.SelectCommand = cmd
+ ' Create the DeleteCommand.
+ cmd = New MySqlCommand("DELETE FROM mytable WHERE id=?id", conn)
- ' Create the UpdateCommand.
- cmd = New MySqlCommand("UPDATE mytable SET id=?id, name=?name WHERE id=?oldId", conn)
+ parm = cmd.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id")
+ parm.SourceVersion = DataRowVersion.Original
- cmd.Parameters.Add( "?id", MySqlDbType.VarChar, 15, "id" )
- cmd.Parameters.Add( "?name", MySqlDbType.VarChar, 15, "name" )
-
- parm = cmd.Parameters.Add("?oldId", MySqlDbType.VarChar, 15, "id")
- parm.SourceVersion = DataRowVersion.Original
-
- da.UpdateCommand = cmd
-
- Return da
-End Function
-</code>
-<code lang="C#">
-public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
-{
- MySqlDataAdapter da = new MySqlDataAdapter();
- MySqlCommand cmd;
- MySqlParameter parm;
+ da.DeleteCommand = cmd
- // Create the SelectCommand.
- cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+ Return da
+ End Function
+ </code>
+ <code lang="C#">
+ public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ MySqlCommand cmd;
+ MySqlParameter parm;
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+ // Create the SelectCommand.
+ cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
- da.SelectCommand = cmd;
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
- // Create the UpdateCommand.
- cmd = new MySqlCommand("UPDATE mytable SET id=?id, name=?name WHERE id=?oldId", conn);
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15, "id" );
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15, "name" );
-
- parm = cmd.Parameters.Add( "?oldId", MySqlDbType.VarChar, 15, "id" );
- parm.SourceVersion = DataRowVersion.Original;
-
- da.UpdateCommand = cmd;
+ da.SelectCommand = cmd;
- return da;
-}
-</code>
- </example>
-</UpdateCommand>
-
-<SelectCommand>
- <summary>
- Gets or sets a SQL statement or stored procedure used to select records in the data source.
- </summary>
- <value>
- A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DbDataAdapter.Fill"/> to select records from the
- database for placement in the <see cref="DataSet"/>.
- </value>
- <remarks>
- <para>When <B>SelectCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
- the <B>MySqlCommand</B> is not cloned. The <B>SelectCommand</B> maintains a reference to the
- previously created <B>MySqlCommand</B> object.
- </para>
- <para>
- If the <B>SelectCommand</B> does not return any rows, no tables are added to the
- <see cref="DataSet"/>, and no exception is raised.
- </para>
- </remarks>
- <example>
-The following example creates a <see cref="MySqlDataAdapter"/> and sets the
-<see cref="SelectCommand"/> and <B>InsertCommand</B> properties. It assumes you have already
-created a <see cref="MySqlConnection"/> object.
-<code lang="Visual Basic">
-Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
-
- Dim da As MySqlDataAdapter = New MySqlDataAdapter()
- Dim cmd As MySqlCommand
- Dim parm As MySqlParameter
+ // Create the DeleteCommand.
+ cmd = new MySqlCommand("DELETE FROM mytable WHERE id=?id", conn);
- ' Create the SelectCommand.
- cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
+ parm = cmd.Parameters.Add("?id", MySqlDbType.VarChar, 5, "id");
+ parm.SourceVersion = DataRowVersion.Original;
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
+ da.DeleteCommand = cmd;
- da.SelectCommand = cmd
+ return da;
+ }
+ </code>
+ </example>
+ </DeleteCommand>
- ' Create the InsertCommand.
- cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id, ?name)", conn)
+ <InsertCommand>
+ <summary>
+ Gets or sets a SQL statement or stored procedure used to insert records into the data set.
+ </summary>
+ <value>
+ A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DataAdapter.Update"/> to insert records into the
+ database that correspond to new rows in the <see cref="DataSet"/>.
+ </value>
+ <remarks>
+ <para>
+ During <see cref="System.Data.Common.DataAdapter.Update"/>, if this property is not set and primary key information
+ is present in the <see cref="DataSet"/>, the <B>InsertCommand</B> can be generated
+ automatically if you set the <see cref="SelectCommand"/> property and use the
+ <see cref="MySqlCommandBuilder"/>. Then, any additional commands that you do not set are
+ generated by the <B>MySqlCommandBuilder</B>. This generation logic requires key column
+ information to be present in the <B>DataSet</B>.
+ </para>
+ <para>
+ When <B>InsertCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
+ the <B>MySqlCommand</B> is not cloned. The <B>InsertCommand</B> maintains a reference
+ to the previously created <B>MySqlCommand</B> object.
+ </para>
+ <note>
+ If execution of this command returns rows, these rows may be added to the <B>DataSet</B>
+ depending on how you set the <see cref="MySqlCommand.UpdatedRowSource"/> property of the <B>MySqlCommand</B> object.
+ </note>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets the
+ <see cref="SelectCommand"/> and <B>InsertCommand</B> properties. It assumes you have already
+ created a <see cref="MySqlConnection"/> object.
+ <code lang="Visual Basic">
+ Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
- cmd.Parameters.Add( "?id", MySqlDbType.VarChar, 15, "id" )
- cmd.Parameters.Add( "?name", MySqlDbType.VarChar, 15, "name" )
- da.InsertCommand = cmd
-
- Return da
-End Function
-</code>
-<code lang="C#">
-public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
-{
- MySqlDataAdapter da = new MySqlDataAdapter();
- MySqlCommand cmd;
- MySqlParameter parm;
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter()
+ Dim cmd As MySqlCommand
+ Dim parm As MySqlParameter
- // Create the SelectCommand.
- cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+ ' Create the SelectCommand.
+ cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
- da.SelectCommand = cmd;
+ da.SelectCommand = cmd
- // Create the InsertCommand.
- cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id,?name)", conn);
- cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15, "id" );
- cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15, "name" );
-
- da.InsertCommand = cmd;
+ ' Create the InsertCommand.
+ cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id, ?name)", conn)
- return da;
-}
-</code>
- </example>
-</SelectCommand>
-
+ cmd.Parameters.Add( "?id", MySqlDbType.VarChar, 15, "id" )
+ cmd.Parameters.Add( "?name", MySqlDbType.VarChar, 15, "name" )
+ da.InsertCommand = cmd
+
+ Return da
+ End Function
+ </code>
+ <code lang="C#">
+ public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ MySqlCommand cmd;
+ MySqlParameter parm;
+
+ // Create the SelectCommand.
+ cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+
+ da.SelectCommand = cmd;
+
+ // Create the InsertCommand.
+ cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id,?name)", conn);
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15, "id" );
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15, "name" );
+
+ da.InsertCommand = cmd;
+
+ return da;
+ }
+ </code>
+ </example>
+ </InsertCommand>
+
+ <UpdateCommand>
+ <summary>
+ Gets or sets a SQL statement or stored procedure used to updated records in the data source.
+ </summary>
+ <value>
+ A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DataAdapter.Update"/> to update records in the
+ database with data from the <see cref="DataSet"/>.
+ </value>
+ <remarks>
+ <para>
+ During <see cref="System.Data.Common.DataAdapter.Update"/>, if this property is not set and primary key information
+ is present in the <see cref="DataSet"/>, the <B>UpdateCommand</B> can be generated
+ automatically if you set the <see cref="SelectCommand"/> property and use the
+ <see cref="MySqlCommandBuilder"/>. Then, any additional commands that you do not set are
+ generated by the <B>MySqlCommandBuilder</B>. This generation logic requires key column
+ information to be present in the <B>DataSet</B>.
+ </para>
+ <para>
+ When <B>UpdateCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
+ the <B>MySqlCommand</B> is not cloned. The <B>UpdateCommand</B> maintains a reference
+ to the previously created <B>MySqlCommand</B> object.
+ </para>
+ <note>
+ If execution of this command returns rows, these rows may be merged with the DataSet
+ depending on how you set the <see cref="MySqlCommand.UpdatedRowSource"/> property of the <B>MySqlCommand</B> object.
+ </note>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets the
+ <see cref="SelectCommand"/> and <B>UpdateCommand</B> properties. It assumes you have already
+ created a <see cref="MySqlConnection"/> object.
+ <code lang="Visual Basic">
+ Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
+
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter()
+ Dim cmd As MySqlCommand
+ Dim parm As MySqlParameter
+
+ ' Create the SelectCommand.
+ cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
+
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
+
+ da.SelectCommand = cmd
+
+ ' Create the UpdateCommand.
+ cmd = New MySqlCommand("UPDATE mytable SET id=?id, name=?name WHERE id=?oldId", conn)
+
+ cmd.Parameters.Add( "?id", MySqlDbType.VarChar, 15, "id" )
+ cmd.Parameters.Add( "?name", MySqlDbType.VarChar, 15, "name" )
+
+ parm = cmd.Parameters.Add("?oldId", MySqlDbType.VarChar, 15, "id")
+ parm.SourceVersion = DataRowVersion.Original
+
+ da.UpdateCommand = cmd
+
+ Return da
+ End Function
+ </code>
+ <code lang="C#">
+ public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ MySqlCommand cmd;
+ MySqlParameter parm;
+
+ // Create the SelectCommand.
+ cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+
+ da.SelectCommand = cmd;
+
+ // Create the UpdateCommand.
+ cmd = new MySqlCommand("UPDATE mytable SET id=?id, name=?name WHERE id=?oldId", conn);
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15, "id" );
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15, "name" );
+
+ parm = cmd.Parameters.Add( "?oldId", MySqlDbType.VarChar, 15, "id" );
+ parm.SourceVersion = DataRowVersion.Original;
+
+ da.UpdateCommand = cmd;
+
+ return da;
+ }
+ </code>
+ </example>
+ </UpdateCommand>
+
+ <SelectCommand>
+ <summary>
+ Gets or sets a SQL statement or stored procedure used to select records in the data source.
+ </summary>
+ <value>
+ A <see cref="MySqlCommand"/> used during <see cref="System.Data.Common.DbDataAdapter.Fill(DataSet)"/>
+ to select records from the database for placement in the <see cref="DataSet"/>.
+ </value>
+ <remarks>
+ <para>
+ When <B>SelectCommand</B> is assigned to a previously created <see cref="MySqlCommand"/>,
+ the <B>MySqlCommand</B> is not cloned. The <B>SelectCommand</B> maintains a reference to the
+ previously created <B>MySqlCommand</B> object.
+ </para>
+ <para>
+ If the <B>SelectCommand</B> does not return any rows, no tables are added to the
+ <see cref="DataSet"/>, and no exception is raised.
+ </para>
+ </remarks>
+ <example>
+ The following example creates a <see cref="MySqlDataAdapter"/> and sets the
+ <see cref="SelectCommand"/> and <B>InsertCommand</B> properties. It assumes you have already
+ created a <see cref="MySqlConnection"/> object.
+ <code lang="Visual Basic">
+ Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
+
+ Dim da As MySqlDataAdapter = New MySqlDataAdapter()
+ Dim cmd As MySqlCommand
+ Dim parm As MySqlParameter
+
+ ' Create the SelectCommand.
+ cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn)
+
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15)
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15)
+
+ da.SelectCommand = cmd
+
+ ' Create the InsertCommand.
+ cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id, ?name)", conn)
+
+ cmd.Parameters.Add( "?id", MySqlDbType.VarChar, 15, "id" )
+ cmd.Parameters.Add( "?name", MySqlDbType.VarChar, 15, "name" )
+ da.InsertCommand = cmd
+
+ Return da
+ End Function
+ </code>
+ <code lang="C#">
+ public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ MySqlCommand cmd;
+ MySqlParameter parm;
+
+ // Create the SelectCommand.
+ cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=?id AND name=?name", conn);
+
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15);
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15);
+
+ da.SelectCommand = cmd;
+
+ // Create the InsertCommand.
+ cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (?id,?name)", conn);
+ cmd.Parameters.Add("?id", MySqlDbType.VarChar, 15, "id" );
+ cmd.Parameters.Add("?name", MySqlDbType.VarChar, 15, "name" );
+
+ da.InsertCommand = cmd;
+
+ return da;
+ }
+ </code>
+ </example>
+ </SelectCommand>
+
</docs>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/docs/MySqlDataReader.xml
===================================================================
--- branches/1.0/mysqlclient/docs/MySqlDataReader.xml 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/docs/MySqlDataReader.xml 2006-10-18 21:25:06 UTC (rev 415)
@@ -1,192 +1,212 @@
<docs>
-<ClassSummary>
-<remarks>
- <para>To create a <B>MySQLDataReader</B>, you must call the <see cref="MySqlCommand.ExecuteReader"/>
- method of the <see cref="MySqlCommand"/> object, rather than directly using a constructor.
- </para>
- <para>While the <B>MySqlDataReader</B> is in use, the associated <see cref="MySqlConnection"/>
- is busy serving the <B>MySqlDataReader</B>, and no other operations can be performed
- on the <B>MySqlConnection</B> other than closing it. This is the case until the
- <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
- </para>
- <para><see cref="MySqlDataReader.IsClosed"/> and <see cref="MySqlDataReader.RecordsAffected"/>
- are the only properties that you can call after the <B>MySqlDataReader</B> is
- closed. Though the <B>RecordsAffected</B> property may be accessed at any time
- while the <B>MySqlDataReader</B> exists, always call <B>Close</B> before returning
- the value of <B>RecordsAffected</B> to ensure an accurate return value.
- </para>
- <para>For optimal performance, <B>MySqlDataReader</B> avoids creating
- unnecessary objects or making unnecessary copies of data. As a result, multiple calls
- to methods such as <see cref="MySqlDataReader.GetValue"/> return a reference to the
- same object. Use caution if you are modifying the underlying value of the objects
- returned by methods such as <B>GetValue</B>.
- </para>
-</remarks>
+ <ClassSummary>
+ <remarks>
+ <para>
+ To create a <B>MySQLDataReader</B>, you must call the <see cref="MySqlCommand.ExecuteReader()"/>
+ method of the <see cref="MySqlCommand"/> object, rather than directly using a constructor.
+ </para>
+ <para>
+ While the <B>MySqlDataReader</B> is in use, the associated <see cref="MySqlConnection"/>
+ is busy serving the <B>MySqlDataReader</B>, and no other operations can be performed
+ on the <B>MySqlConnection</B> other than closing it. This is the case until the
+ <see cref="MySqlDataReader.Close"/> method of the <B>MySqlDataReader</B> is called.
+ </para>
+ <para>
+ <see cref="MySqlDataReader.IsClosed"/> and <see cref="MySqlDataReader.RecordsAffected"/>
+ are the only properties that you can call after the <B>MySqlDataReader</B> is
+ closed. Though the <B>RecordsAffected</B> property may be accessed at any time
+ while the <B>MySqlDataReader</B> exists, always call <B>Close</B> before returning
+ the value of <B>RecordsAffected</B> to ensure an accurate return value.
+ </para>
+ <para>
+ For optimal performance, <B>MySqlDataReader</B> avoids creating
+ unnecessary objects or making unnecessary copies of data. As a result, multiple calls
+ to methods such as <see cref="MySqlDataReader.GetValue"/> return a reference to the
+ same object. Use caution if you are modifying the underlying value of the objects
+ returned by methods such as <B>GetValue</B>.
+ </para>
+ </remarks>
-<example>
- The following example creates a <see cref="MySqlConnection"/>,
- a <see cref="MySqlCommand"/>, and a <B>MySqlDataReader</B>. The example reads through
- the data, writing it out to the console. Finally, the example closes the <B>MySqlDataReader</B>, then the
- <B>MySqlConnection</B>.
- <code lang="Visual Basic">
-Public Sub ReadMyData(myConnString As String)
- Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"
- Dim myConnection As New MySqlConnection(myConnString)
- Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
- myConnection.Open()
- Dim myReader As MySqlDataReader
- myReader = myCommand.ExecuteReader()
- ' Always call Read before accessing data.
- While myReader.Read()
+ <example>
+ The following example creates a <see cref="MySqlConnection"/>,
+ a <see cref="MySqlCommand"/>, and a <B>MySqlDataReader</B>. The example reads through
+ the data, writing it out to the console. Finally, the example closes the <B>MySqlDataReader</B>, then the
+ <B>MySqlConnection</B>.
+ <code lang="Visual Basic">
+ Public Sub ReadMyData(myConnString As String)
+ Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders"
+ Dim myConnection As New MySqlConnection(myConnString)
+ Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
+ myConnection.Open()
+ Dim myReader As MySqlDataReader
+ myReader = myCommand.ExecuteReader()
+ ' Always call Read before accessing data.
+ While myReader.Read()
Console.WriteLine((myReader.GetInt32(0) & ", " & myReader.GetString(1)))
- End While
- ' always call Close when done reading.
- myReader.Close()
- ' Close the connection when done with it.
- myConnection.Close()
-End Sub 'ReadMyData
- </code>
- <code lang="C#">
-public void ReadMyData(string myConnString) {
- string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
- myConnection.Open();
- MySqlDataReader myReader;
- myReader = myCommand.ExecuteReader();
- // Always call Read before accessing data.
- while (myReader.Read()) {
- Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
- }
- // always call Close when done reading.
- myReader.Close();
- // Close the connection when done with it.
- myConnection.Close();
- }
- </code>
-</example>
-</ClassSummary>
+ End While
+ ' always call Close when done reading.
+ myReader.Close()
+ ' Close the connection when done with it.
+ myConnection.Close()
+ End Sub 'ReadMyData
+ </code>
+ <code lang="C#">
+ public void ReadMyData(string myConnString) {
+ string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
+ myConnection.Open();
+ MySqlDataReader myReader;
+ myReader = myCommand.ExecuteReader();
+ // Always call Read before accessing data.
+ while (myReader.Read()) {
+ Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
+ }
+ // always call Close when done reading.
+ myReader.Close();
+ // Close the connection when done with it.
+ myConnection.Close();
+ }
+ </code>
+ </example>
+ </ClassSummary>
-<GetBytes>
- <remarks>
- <para><B>GetBytes</B> returns the number of available bytes in the field. In most
- cases this is the exact length of the field. However, the number returned may be
- less than the true length of the field if <B>GetBytes</B> has already been used
- to obtain bytes from the field. This may be the case, for example, if the
- <see cref="MySqlDataReader"/> is reading a large data structure into a buffer.
- For more information, see the <B>SequentialAccess</B> setting for
- <see cref="MySqlCommand.CommandBehavior"/>.</para>
- <para>If you pass a buffer that is a null reference (<B>Nothing</B> in Visual
- Basic), <B>GetBytes</B> returns the length of the field in bytes.</para>
- <para>No conversions are performed; therefore the data retrieved must already be a
- byte array.</para>
- </remarks>
-</GetBytes>
+ <GetBytes>
+ <remarks>
+ <para>
+ <B>GetBytes</B> returns the number of available bytes in the field. In most
+ cases this is the exact length of the field. However, the number returned may be
+ less than the true length of the field if <B>GetBytes</B> has already been used
+ to obtain bytes from the field. This may be the case, for example, if the
+ <see cref="MySqlDataReader"/> is reading a large data structure into a buffer.
+ For more information, see the <B>SequentialAccess</B> setting for
+ <see cref="MySqlCommand.CommandBehavior"/>.
+ </para>
+ <para>
+ If you pass a buffer that is a null reference (<B>Nothing</B> in Visual
+ Basic), <B>GetBytes</B> returns the length of the field in bytes.
+ </para>
+ <para>
+ No conversions are performed; therefore the data retrieved must already be a
+ byte array.
+ </para>
+ </remarks>
+ </GetBytes>
-<GetTimeSpan>
- <summary>Gets the value of the specified column as a <see cref="TimeSpan"/> object.</summary>
- <remarks>
- </remarks>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetTimeSpan>
+ <GetTimeSpan>
+ <summary>
+ Gets the value of the specified column as a <see cref="TimeSpan"/> object.
+ </summary>
+ <remarks>
+ </remarks>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetTimeSpan>
-<GetDateTime>
- <summary>Gets the value of the specified column as a <see cref="DateTime"/> object.</summary>
- <remarks>
- <note>
- <para>
- MySql allows date columns to contain the value '0000-00-00' and datetime
- columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain
- or represent these values. To read a datetime value from a column that might
- contain zero values, use <see cref="GetMySqlDateTime"/>.
- </para>
- <para>
- The behavior of reading a zero datetime column using this method is defined by the
- <i>ZeroDateTimeBehavior</i> connection string option. For more information on this option,
- please refer to <see cref="MySqlConnection.ConnectionString"/>.
- </para>
- </note>
- </remarks>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetDateTime>
+ <GetDateTime>
+ <summary>
+ Gets the value of the specified column as a <see cref="DateTime"/> object.
+ </summary>
+ <remarks>
+ <note>
+ <para>
+ MySql allows date columns to contain the value '0000-00-00' and datetime
+ columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain
+ or represent these values. To read a datetime value from a column that might
+ contain zero values, use <see cref="GetMySqlDateTime"/>.
+ </para>
+ <para>
+ The behavior of reading a zero datetime column using this method is defined by the
+ <i>ZeroDateTimeBehavior</i> connection string option. For more information on this option,
+ please refer to <see cref="MySqlConnection.ConnectionString"/>.
+ </para>
+ </note>
+ </remarks>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetDateTime>
-<GetMySqlDateTime>
- <summary>Gets the value of the specified column as a <see cref="MySql.Data.Types.MySqlDateTime"/> object.</summary>
- <remarks>
- </remarks>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetMySqlDateTime>
+ <GetMySqlDateTime>
+ <summary>
+ Gets the value of the specified column as a <see cref="MySql.Data.Types.MySqlDateTime"/> object.
+ </summary>
+ <remarks>
+ </remarks>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetMySqlDateTime>
-<GetString>
- <summary>Gets the value of the specified column as a <see cref="String"/> object.</summary>
- <remarks></remarks>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetString>
+ <GetString>
+ <summary>
+ Gets the value of the specified column as a <see cref="String"/> object.
+ </summary>
+ <remarks></remarks>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetString>
-<GetDecimal>
- <summary>Gets the value of the specified column as a <see cref="Decimal"/> object.</summary>
- <remarks></remarks>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetDecimal>
+ <GetDecimal>
+ <summary>
+ Gets the value of the specified column as a <see cref="Decimal"/> object.
+ </summary>
+ <remarks></remarks>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetDecimal>
-<GetDouble>
- <summary>Gets the value of the specified column as a double-precision floating point number.</summary>
- <remarks></remarks>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetDouble>
+ <GetDouble>
+ <summary>Gets the value of the specified column as a double-precision floating point number.</summary>
+ <remarks></remarks>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetDouble>
-<GetFloat>
- <summary>Gets the value of the specified column as a single-precision floating point number.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetFloat>
+ <GetFloat>
+ <summary>Gets the value of the specified column as a single-precision floating point number.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetFloat>
-<GetGiud>
- <summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetGiud>
+ <GetGiud>
+ <summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetGiud>
-<GetInt16>
- <summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetInt16>
+ <GetInt16>
+ <summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetInt16>
-<GetInt32>
- <summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetInt32>
+ <GetInt32>
+ <summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetInt32>
-<GetInt64>
- <summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetInt64>
+ <GetInt64>
+ <summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetInt64>
-<GetUInt16>
- <summary>Gets the value of the specified column as a 16-bit unsigned integer.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetUInt16>
+ <GetUInt16>
+ <summary>Gets the value of the specified column as a 16-bit unsigned integer.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetUInt16>
-<GetUInt32>
- <summary>Gets the value of the specified column as a 32-bit unsigned integer.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetUInt32>
+ <GetUInt32>
+ <summary>Gets the value of the specified column as a 32-bit unsigned integer.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetUInt32>
-<GetUInt64>
- <summary>Gets the value of the specified column as a 64-bit unsigned integer.</summary>
- <param name="index">The zero-based column ordinal.</param>
- <returns>The value of the specified column.</returns>
-</GetUInt64>
+ <GetUInt64>
+ <summary>Gets the value of the specified column as a 64-bit unsigned integer.</summary>
+ <param name="index">The zero-based column ordinal.</param>
+ <returns>The value of the specified column.</returns>
+ </GetUInt64>
</docs>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/docs/MySqlTransaction.xml
===================================================================
--- branches/1.0/mysqlclient/docs/MySqlTransaction.xml 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/docs/MySqlTransaction.xml 2006-10-18 21:25:06 UTC (rev 415)
@@ -1,329 +1,330 @@
-<docs>
-<Class>
- <summary>
- Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited.
- </summary>
-
-<remarks>
- The application creates a <B>MySqlTransaction</B> object by calling <see cref="MySqlConnection.BeginTransaction"/>
- on the <see cref="MySqlConnection"/> object. All subsequent operations associated with the
- transaction (for example, committing or aborting the transaction), are performed on the
- <B>MySqlTransaction</B> object.
-</remarks>
-
-<example>
- The following example creates a <see cref="MySqlConnection"/> and a <B>MySqlTransaction</B>.
- It also demonstrates how to use the <see cref="MySqlConnection.BeginTransaction"/>,
- <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
- <code lang="Visual Basic">
-Public Sub RunTransaction(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
-
- Dim myCommand As MySqlCommand = myConnection.CreateCommand()
- Dim myTrans As MySqlTransaction
-
- ' Start a local transaction
- myTrans = myConnection.BeginTransaction()
- ' Must assign both transaction object and connection
- ' to Command object for a pending local transaction
- myCommand.Connection = myConnection
- myCommand.Transaction = myTrans
-
- Try
- myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"
- myCommand.ExecuteNonQuery()
- myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"
- myCommand.ExecuteNonQuery()
- myTrans.Commit()
- Console.WriteLine("Both records are written to database.")
- Catch e As Exception
- Try
- myTrans.Rollback()
- Catch ex As MySqlException
- If Not myTrans.Connection Is Nothing Then
- Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
- " was encountered while attempting to roll back the transaction.")
- End If
- End Try
-
- Console.WriteLine("An exception of type " & e.GetType().ToString() & _
- "was encountered while inserting the data.")
- Console.WriteLine("Neither record was written to database.")
- Finally
- myConnection.Close()
- End Try
-End Sub 'RunTransaction
- </code>
- <code lang="C#">
-public void RunTransaction(string myConnString)
- {
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
-
- MySqlCommand myCommand = myConnection.CreateCommand();
- MySqlTransaction myTrans;
-
- // Start a local transaction
- myTrans = myConnection.BeginTransaction();
- // Must assign both transaction object and connection
- // to Command object for a pending local transaction
- myCommand.Connection = myConnection;
- myCommand.Transaction = myTrans;
-
- try
- {
- myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";
- myCommand.ExecuteNonQuery();
- myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";
- myCommand.ExecuteNonQuery();
- myTrans.Commit();
- Console.WriteLine("Both records are written to database.");
- }
- catch(Exception e)
- {
- try
- {
- myTrans.Rollback();
- }
- catch (MySqlException ex)
- {
- if (myTrans.Connection != null)
- {
- Console.WriteLine("An exception of type " + ex.GetType() +
- " was encountered while attempting to roll back the transaction.");
- }
- }
-
- Console.WriteLine("An exception of type " + e.GetType() +
- " was encountered while inserting the data.");
- Console.WriteLine("Neither record was written to database.");
- }
- finally
- {
- myConnection.Close();
- }
-}
- </code>
-</example>
-
-
-</Class>
-
-<Rollback>
- <summary>
- Rolls back a transaction from a pending state.
- </summary>
- <remarks>
- The Rollback method is equivalent to the MySQL statement ROLLBACK.
- The transaction can only be rolled back from a pending state
- (after BeginTransaction has been called, but before Commit is
- called).
- </remarks>
- <example>
-The following example creates <see cref="MySqlConnection"/> and a
-<see cref="MySqlTransaction"/>. It also demonstrates how to use the
-<see cref="MySqlConnection.BeginTransaction"/>, <see cref="Commit"/>, and <B>Rollback</B>
-methods.
-<code lang="Visual Basic">
-Public Sub RunSqlTransaction(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
-
- Dim myCommand As MySqlCommand = myConnection.CreateCommand()
- Dim myTrans As MySqlTransaction
-
- ' Start a local transaction
- myTrans = myConnection.BeginTransaction()
-
- ' Must assign both transaction object and connection
- ' to Command object for a pending local transaction
- myCommand.Connection = myConnection
- myCommand.Transaction = myTrans
-
- Try
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"
- myCommand.ExecuteNonQuery()
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"
- myCommand.ExecuteNonQuery()
- myTrans.Commit()
- Console.WriteLine("Success.")
- Catch e As Exception
- Try
+<?xml version="1.0" encoding="Windows-1252"?>
+<docs>
+ <Class>
+ <summary>
+ Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited.
+ </summary>
+
+ <remarks>
+ The application creates a <B>MySqlTransaction</B> object by calling
+ <see cref="MySqlConnection.BeginTransaction()"/> on the <see cref="MySqlConnection"/> object. All subsequent operations associated with the
+ transaction (for example, committing or aborting the transaction), are performed on the
+ <B>MySqlTransaction</B> object.
+ </remarks>
+
+ <example>
+ The following example creates a <see cref="MySqlConnection"/> and a <B>MySqlTransaction</B>.
+ It also demonstrates how to use the <see cref="MySqlConnection.BeginTransaction()"/>,
+ <see cref="MySqlTransaction.Commit"/>, and <see cref="MySqlTransaction.Rollback"/> methods.
+ <code lang="Visual Basic">
+ Public Sub RunTransaction(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+
+ Dim myCommand As MySqlCommand = myConnection.CreateCommand()
+ Dim myTrans As MySqlTransaction
+
+ ' Start a local transaction
+ myTrans = myConnection.BeginTransaction()
+ ' Must assign both transaction object and connection
+ ' to Command object for a pending local transaction
+ myCommand.Connection = myConnection
+ myCommand.Transaction = myTrans
+
+ Try
+ myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myTrans.Commit()
+ Console.WriteLine("Both records are written to database.")
+ Catch e As Exception
+ Try
myTrans.Rollback()
- Catch ex As MySqlException
+ Catch ex As MySqlException
If Not myTrans.Connection Is Nothing Then
- Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
- " was encountered while attempting to roll back the transaction.")
+ Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
+ " was encountered while attempting to roll back the transaction.")
End If
- End Try
-
- Console.WriteLine("An exception of type " & e.GetType().ToString() & _
- "was encountered while inserting the data.")
- Console.WriteLine("Neither record was written to database.")
- Finally
- myConnection.Close()
- End Try
-End Sub
-</code>
-<code lang="C#">
-public void RunSqlTransaction(string myConnString)
- {
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
+ End Try
- MySqlCommand myCommand = myConnection.CreateCommand();
- MySqlTransaction myTrans;
+ Console.WriteLine("An exception of type " & e.GetType().ToString() & _
+ "was encountered while inserting the data.")
+ Console.WriteLine("Neither record was written to database.")
+ Finally
+ myConnection.Close()
+ End Try
+ End Sub 'RunTransaction
+ </code>
+ <code lang="C#">
+ public void RunTransaction(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
- // Start a local transaction
- myTrans = myConnection.BeginTransaction();
- // Must assign both transaction object and connection
- // to Command object for a pending local transaction
- myCommand.Connection = myConnection;
- myCommand.Transaction = myTrans;
+ MySqlCommand myCommand = myConnection.CreateCommand();
+ MySqlTransaction myTrans;
- try
- {
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')";
- myCommand.ExecuteNonQuery();
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')";
- myCommand.ExecuteNonQuery();
- myTrans.Commit();
- Console.WriteLine("Both records are written to database.");
- }
- catch(Exception e)
- {
- try
- {
+ // Start a local transaction
+ myTrans = myConnection.BeginTransaction();
+ // Must assign both transaction object and connection
+ // to Command object for a pending local transaction
+ myCommand.Connection = myConnection;
+ myCommand.Transaction = myTrans;
+
+ try
+ {
+ myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myTrans.Commit();
+ Console.WriteLine("Both records are written to database.");
+ }
+ catch(Exception e)
+ {
+ try
+ {
myTrans.Rollback();
- }
- catch (MySqlException ex)
- {
+ }
+ catch (MySqlException ex)
+ {
if (myTrans.Connection != null)
{
- Console.WriteLine("An exception of type " + ex.GetType() +
- " was encountered while attempting to roll back the transaction.");
+ Console.WriteLine("An exception of type " + ex.GetType() +
+ " was encountered while attempting to roll back the transaction.");
}
- }
-
- Console.WriteLine("An exception of type " + e.GetType() +
- " was encountered while inserting the data.");
- Console.WriteLine("Neither record was written to database.");
- }
- finally
- {
- myConnection.Close();
- }
-}
-</code>
- </example>
-</Rollback>
-
-<Commit>
- <summary>
- Commits the database transaction.
- </summary>
- <remarks>
- The <b>Commit</b> method is equivalent to the MySQL SQL statement
- COMMIT.
- </remarks>
- <example>
-The following example creates <see cref="MySqlConnection"/> and a
-<see cref="MySqlTransaction"/>. It also demonstrates how to use the
-<see cref="MySqlConnection.BeginTransaction"/>, <see cref="Commit"/>, and <B>Rollback</B>
-methods.
-<code lang="Visual Basic">
-Public Sub RunSqlTransaction(myConnString As String)
- Dim myConnection As New MySqlConnection(myConnString)
- myConnection.Open()
-
- Dim myCommand As MySqlCommand = myConnection.CreateCommand()
- Dim myTrans As MySqlTransaction
-
- ' Start a local transaction
- myTrans = myConnection.BeginTransaction()
-
- ' Must assign both transaction object and connection
- ' to Command object for a pending local transaction
- myCommand.Connection = myConnection
- myCommand.Transaction = myTrans
-
- Try
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"
- myCommand.ExecuteNonQuery()
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"
- myCommand.ExecuteNonQuery()
- myTrans.Commit()
- Console.WriteLine("Success.")
- Catch e As Exception
- Try
+ }
+
+ Console.WriteLine("An exception of type " + e.GetType() +
+ " was encountered while inserting the data.");
+ Console.WriteLine("Neither record was written to database.");
+ }
+ finally
+ {
+ myConnection.Close();
+ }
+ }
+ </code>
+ </example>
+
+
+ </Class>
+
+ <Rollback>
+ <summary>
+ Rolls back a transaction from a pending state.
+ </summary>
+ <remarks>
+ The Rollback method is equivalent to the MySQL statement ROLLBACK.
+ The transaction can only be rolled back from a pending state
+ (after BeginTransaction has been called, but before Commit is
+ called).
+ </remarks>
+ <example>
+ The following example creates <see cref="MySqlConnection"/> and a
+ <see cref="MySqlTransaction"/>. It also demonstrates how to use the
+ <see cref="MySqlConnection.BeginTransaction()"/>, <see cref="Commit"/>, and <B>Rollback</B>
+ methods.
+ <code lang="Visual Basic">
+ Public Sub RunSqlTransaction(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+
+ Dim myCommand As MySqlCommand = myConnection.CreateCommand()
+ Dim myTrans As MySqlTransaction
+
+ ' Start a local transaction
+ myTrans = myConnection.BeginTransaction()
+
+ ' Must assign both transaction object and connection
+ ' to Command object for a pending local transaction
+ myCommand.Connection = myConnection
+ myCommand.Transaction = myTrans
+
+ Try
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myTrans.Commit()
+ Console.WriteLine("Success.")
+ Catch e As Exception
+ Try
myTrans.Rollback()
- Catch ex As MySqlException
+ Catch ex As MySqlException
If Not myTrans.Connection Is Nothing Then
- Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
- " was encountered while attempting to roll back the transaction.")
+ Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
+ " was encountered while attempting to roll back the transaction.")
End If
- End Try
-
- Console.WriteLine("An exception of type " & e.GetType().ToString() & _
- "was encountered while inserting the data.")
- Console.WriteLine("Neither record was written to database.")
- Finally
- myConnection.Close()
- End Try
-End Sub
-</code>
-<code lang="C#">
-public void RunSqlTransaction(string myConnString)
- {
- MySqlConnection myConnection = new MySqlConnection(myConnString);
- myConnection.Open();
+ End Try
- MySqlCommand myCommand = myConnection.CreateCommand();
- MySqlTransaction myTrans;
+ Console.WriteLine("An exception of type " & e.GetType().ToString() & _
+ "was encountered while inserting the data.")
+ Console.WriteLine("Neither record was written to database.")
+ Finally
+ myConnection.Close()
+ End Try
+ End Sub
+ </code>
+ <code lang="C#">
+ public void RunSqlTransaction(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
- // Start a local transaction
- myTrans = myConnection.BeginTransaction();
- // Must assign both transaction object and connection
- // to Command object for a pending local transaction
- myCommand.Connection = myConnection;
- myCommand.Transaction = myTrans;
+ MySqlCommand myCommand = myConnection.CreateCommand();
+ MySqlTransaction myTrans;
- try
- {
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')";
- myCommand.ExecuteNonQuery();
- myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')";
- myCommand.ExecuteNonQuery();
- myTrans.Commit();
- Console.WriteLine("Both records are written to database.");
- }
- catch(Exception e)
- {
- try
- {
+ // Start a local transaction
+ myTrans = myConnection.BeginTransaction();
+ // Must assign both transaction object and connection
+ // to Command object for a pending local transaction
+ myCommand.Connection = myConnection;
+ myCommand.Transaction = myTrans;
+
+ try
+ {
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myTrans.Commit();
+ Console.WriteLine("Both records are written to database.");
+ }
+ catch(Exception e)
+ {
+ try
+ {
myTrans.Rollback();
- }
- catch (MySqlException ex)
- {
+ }
+ catch (MySqlException ex)
+ {
if (myTrans.Connection != null)
{
- Console.WriteLine("An exception of type " + ex.GetType() +
- " was encountered while attempting to roll back the transaction.");
+ Console.WriteLine("An exception of type " + ex.GetType() +
+ " was encountered while attempting to roll back the transaction.");
}
- }
-
- Console.WriteLine("An exception of type " + e.GetType() +
- " was encountered while inserting the data.");
- Console.WriteLine("Neither record was written to database.");
- }
- finally
- {
- myConnection.Close();
- }
-}
-</code>
- </example>
-</Commit>
-
+ }
+
+ Console.WriteLine("An exception of type " + e.GetType() +
+ " was encountered while inserting the data.");
+ Console.WriteLine("Neither record was written to database.");
+ }
+ finally
+ {
+ myConnection.Close();
+ }
+ }
+ </code>
+ </example>
+ </Rollback>
+
+ <Commit>
+ <summary>
+ Commits the database transaction.
+ </summary>
+ <remarks>
+ The <b>Commit</b> method is equivalent to the MySQL SQL statement
+ COMMIT.
+ </remarks>
+ <example>
+ The following example creates <see cref="MySqlConnection"/> and a
+ <see cref="MySqlTransaction"/>. It also demonstrates how to use the
+ <see cref="MySqlConnection.BeginTransaction()"/>, <see cref="Commit"/>, and <B>Rollback</B>
+ methods.
+ <code lang="Visual Basic">
+ Public Sub RunSqlTransaction(myConnString As String)
+ Dim myConnection As New MySqlConnection(myConnString)
+ myConnection.Open()
+
+ Dim myCommand As MySqlCommand = myConnection.CreateCommand()
+ Dim myTrans As MySqlTransaction
+
+ ' Start a local transaction
+ myTrans = myConnection.BeginTransaction()
+
+ ' Must assign both transaction object and connection
+ ' to Command object for a pending local transaction
+ myCommand.Connection = myConnection
+ myCommand.Transaction = myTrans
+
+ Try
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"
+ myCommand.ExecuteNonQuery()
+ myTrans.Commit()
+ Console.WriteLine("Success.")
+ Catch e As Exception
+ Try
+ myTrans.Rollback()
+ Catch ex As MySqlException
+ If Not myTrans.Connection Is Nothing Then
+ Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
+ " was encountered while attempting to roll back the transaction.")
+ End If
+ End Try
+
+ Console.WriteLine("An exception of type " & e.GetType().ToString() & _
+ "was encountered while inserting the data.")
+ Console.WriteLine("Neither record was written to database.")
+ Finally
+ myConnection.Close()
+ End Try
+ End Sub
+ </code>
+ <code lang="C#">
+ public void RunSqlTransaction(string myConnString)
+ {
+ MySqlConnection myConnection = new MySqlConnection(myConnString);
+ myConnection.Open();
+
+ MySqlCommand myCommand = myConnection.CreateCommand();
+ MySqlTransaction myTrans;
+
+ // Start a local transaction
+ myTrans = myConnection.BeginTransaction();
+ // Must assign both transaction object and connection
+ // to Command object for a pending local transaction
+ myCommand.Connection = myConnection;
+ myCommand.Transaction = myTrans;
+
+ try
+ {
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')";
+ myCommand.ExecuteNonQuery();
+ myTrans.Commit();
+ Console.WriteLine("Both records are written to database.");
+ }
+ catch(Exception e)
+ {
+ try
+ {
+ myTrans.Rollback();
+ }
+ catch (MySqlException ex)
+ {
+ if (myTrans.Connection != null)
+ {
+ Console.WriteLine("An exception of type " + ex.GetType() +
+ " was encountered while attempting to roll back the transaction.");
+ }
+ }
+
+ Console.WriteLine("An exception of type " + e.GetType() +
+ " was encountered while inserting the data.");
+ Console.WriteLine("Neither record was written to database.");
+ }
+ finally
+ {
+ myConnection.Close();
+ }
+ }
+ </code>
+ </example>
+ </Commit>
+
</docs>
\ No newline at end of file
Modified: branches/1.0/mysqlclient/parameter_collection.cs
===================================================================
--- branches/1.0/mysqlclient/parameter_collection.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/parameter_collection.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -45,7 +45,7 @@
private Hashtable ciHash;
private Hashtable hash;
- public MySqlParameterCollection()
+ internal MySqlParameterCollection()
{
hash = new Hashtable();
#if NET20
Modified: branches/1.0/mysqlclient/transaction.cs
===================================================================
--- branches/1.0/mysqlclient/transaction.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/transaction.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -52,7 +52,7 @@
/// A single application may have multiple database connections, each
/// with zero or more transactions. This property enables you to
/// determine the connection object associated with a particular
- /// transaction created by <see cref="MySqlConnection.BeginTransaction"/>.
+ /// transaction created by <see cref="MySqlConnection.BeginTransaction()"/>.
/// </remarks>
public MySqlConnection Connection
{
Modified: branches/1.0/mysqlclient/zlib/Deflate.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/Deflate.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/Deflate.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -45,7 +45,7 @@
namespace zlib
{
- public sealed class Deflate
+ internal sealed class Deflate
{
private const int MAX_MEM_LEVEL = 9;
Modified: branches/1.0/mysqlclient/zlib/SupportClass.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/SupportClass.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/SupportClass.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -3,7 +3,7 @@
/* Contains conversion support elements such as classes, interfaces and static methods. */
namespace zlib
{
- public class SupportClass
+ internal class SupportClass
{
/// <summary>
/// This method returns the literal value received
Modified: branches/1.0/mysqlclient/zlib/ZInputStream.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/ZInputStream.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/ZInputStream.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -45,7 +45,10 @@
namespace zlib
{
- public class ZInputStream:System.IO.BinaryReader
+ /// <summary>
+ ///
+ /// </summary>
+ internal class ZInputStream:System.IO.BinaryReader
{
public long maxInput;
@@ -54,6 +57,7 @@
flush = zlibConst.Z_NO_FLUSH;
buf = new byte[bufsize];
}
+
virtual public int FlushMode
{
get
Modified: branches/1.0/mysqlclient/zlib/ZOutputStream.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/ZOutputStream.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/ZOutputStream.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -46,7 +46,7 @@
namespace zlib
{
- public class ZOutputStream:System.IO.Stream
+ internal class ZOutputStream:System.IO.Stream
{
private void InitBlock()
{
Modified: branches/1.0/mysqlclient/zlib/ZStream.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/ZStream.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/ZStream.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -45,7 +45,7 @@
namespace zlib
{
- sealed public class ZStream
+ sealed internal class ZStream
{
private const int MAX_WBITS = 15; // 32K LZ77 window
Modified: branches/1.0/mysqlclient/zlib/ZStreamException.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/ZStreamException.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/ZStreamException.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -46,7 +46,7 @@
{
[Serializable]
- public class ZStreamException:System.IO.IOException
+ internal class ZStreamException:System.IO.IOException
{
public ZStreamException():base()
{
Modified: branches/1.0/mysqlclient/zlib/Zlib.cs
===================================================================
--- branches/1.0/mysqlclient/zlib/Zlib.cs 2006-10-18 20:29:50 UTC (rev 414)
+++ branches/1.0/mysqlclient/zlib/Zlib.cs 2006-10-18 21:25:06 UTC (rev 415)
@@ -44,8 +44,10 @@
using System;
namespace zlib
{
-
- sealed public class zlibConst
+ /// <summary>
+ ///
+ /// </summary>
+ sealed internal class zlibConst
{
private const System.String version_Renamed_Field = "1.0.2";
public static System.String version()
| Thread |
|---|
| • Connector/NET commit: r415 - in branches/1.0/mysqlclient: . Types common docs zlib | rburnett | 18 Oct |