1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Updated Nuget Packages.

Optimized Blacklist module to not use locks.
This commit is contained in:
Uncled1023 2018-01-28 01:06:15 -08:00
parent 28e6c34748
commit 3b17dd9e76
62 changed files with 12846 additions and 1179 deletions

View File

@ -57,12 +57,10 @@
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
@ -77,8 +75,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings configSource="ConnectionStrings.config" />
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
@ -30,11 +30,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net452" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="EntityFramework" version="6.2.0" targetFramework="net462" />
<package id="GitVersionTask" version="3.6.5" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net452" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net452" />
<package id="nClam" version="2.0.6.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net462" />
</packages>

View File

@ -33,56 +33,11 @@ namespace Teknik.Modules
context.BeginRequest += onBeginRequest;
}
#region Referrer Info
private const string BLOCKEDREFERRERKEY = "BlockedReferrer";
private static string referrerFileName = null;
private static object referrerFileNameObj = new object();
public static string GetReferrerFilePath()
{
if (referrerFileName != null)
return referrerFileName;
lock (referrerFileNameObj)
{
if (referrerFileName == null)
{
Config config = Config.Load();
referrerFileName = config.ReferrerBlacklistFile;
}
}
return referrerFileName;
}
#endregion
#region IP Info
private const string BLOCKEDIPKEY = "BlockedIP";
private static string ipFileName = null;
private static object ipFileNameObj = new object();
public static string GetIPFilePath()
{
if (ipFileName != null)
return ipFileName;
lock (ipFileNameObj)
{
if (ipFileName == null)
{
Config config = Config.Load();
ipFileName = config.IPBlacklistFile;
}
}
return ipFileName;
}
#endregion
public static StringDictionary GetFileData(HttpContext context, string key, Func<string> fn)
public static StringDictionary GetFileData(HttpContext context, string key, string filePath)
{
StringDictionary data = (StringDictionary)context.Cache[key];
if (data == null)
{
string filePath = fn();
data = GetFileLines(filePath);
context.Cache.Insert(key, data, new CacheDependency(filePath));
}
@ -118,6 +73,8 @@ namespace Teknik.Modules
if (app != null)
{
Config config = Config.Load();
bool blocked = false;
string blockReason = string.Empty;
@ -127,7 +84,7 @@ namespace Teknik.Modules
string IPAddr = app.Context.Request.ServerVariables["REMOTE_ADDR"];
if (!string.IsNullOrEmpty(IPAddr))
{
StringDictionary badIPs = GetFileData(app.Context, BLOCKEDIPKEY, GetIPFilePath);
StringDictionary badIPs = GetFileData(app.Context, "BlockedIPs", config.IPBlacklistFile);
blocked |= (badIPs != null && badIPs.ContainsKey(IPAddr));
blockReason = $"This IP address ({IPAddr}) has been blacklisted. If you feel this is in error, please contact support@teknik.io for assistance.";
@ -141,7 +98,7 @@ namespace Teknik.Modules
string referrer = app.Context.Request.UrlReferrer?.Host;
if (!string.IsNullOrEmpty(referrer))
{
StringDictionary badReferrers = GetFileData(app.Context, BLOCKEDREFERRERKEY, GetReferrerFilePath);
StringDictionary badReferrers = GetFileData(app.Context, "BlockedReferrers", config.ReferrerBlacklistFile);
blocked |= (badReferrers != null && badReferrers.ContainsKey(referrer));
blockReason = $"This referrer ({referrer}) has been blacklisted. If you feel this is in error, please contact support@teknik.io for assistance.";

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2
Teknik/Scripts/jquery-3.3.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/* jquery.signalR.core.js */
/*global window:false */
/*!
* ASP.NET SignalR JavaScript Library v2.2.1
* ASP.NET SignalR JavaScript Library v2.2.2
* http://signalr.net/
*
* Copyright (c) .NET Foundation. All rights reserved.
@ -950,6 +950,9 @@
// Clear out our message buffer
connection._.connectingMessageBuffer.clear();
// Clean up this event
$(connection).unbind(events.onStart);
// Trigger the disconnect event
changeState(connection, connection.state, signalR.connectionState.disconnected);
@ -2227,8 +2230,8 @@
}
// Ensure the iframe is where we left it
if (connection.frame.parentNode === window.document.body) {
window.document.body.removeChild(connection.frame);
if (connection.frame.parentNode === window.document.documentElement) {
window.document.documentElement.removeChild(connection.frame);
}
delete transportLogic.foreverFrame.connections[connection.frameId];
@ -2951,5 +2954,5 @@
/*global window:false */
/// <reference path="jquery.signalR.core.js" />
(function ($, undefined) {
$.signalR.version = "2.2.1";
$.signalR.version = "2.2.2";
}(window.jQuery));

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* intended to be used only for design-time IntelliSense. Please use the
* standard jQuery library for all production use.
*
* Comment version: 1.16.0
* Comment version: 1.17.0
*/
/*
@ -15,7 +15,7 @@
* for informational purposes only and are not the license terms under
* which Microsoft distributed this file.
*
* jQuery Validation Plugin - v1.16.0 - 12/5/2016
* jQuery Validation Plugin - v1.17.0 - 12/5/2016
* https://github.com/jzaefferer/jquery-validation
* Copyright (c) 2013 Jörn Zaefferer; Licensed MIT
*

View File

@ -1,9 +1,9 @@
/*!
* jQuery Validation Plugin v1.16.0
* jQuery Validation Plugin v1.17.0
*
* http://jqueryvalidation.org/
* https://jqueryvalidation.org/
*
* Copyright (c) 2016 Jörn Zaefferer
* Copyright (c) 2017 Jörn Zaefferer
* Released under the MIT license
*/
(function( factory ) {
@ -18,7 +18,7 @@
$.extend( $.fn, {
// http://jqueryvalidation.org/validate/
// https://jqueryvalidation.org/validate/
validate: function( options ) {
// If nothing is selected, return nothing; can't chain anyway
@ -44,9 +44,10 @@ $.extend( $.fn, {
if ( validator.settings.onsubmit ) {
this.on( "click.validate", ":submit", function( event ) {
if ( validator.settings.submitHandler ) {
validator.submitButton = event.target;
}
// Track the used submit button to properly handle scripted
// submits later.
validator.submitButton = event.currentTarget;
// Allow suppressing validation by adding a cancel class to the submit button
if ( $( this ).hasClass( "cancel" ) ) {
@ -68,17 +69,22 @@ $.extend( $.fn, {
}
function handle() {
var hidden, result;
if ( validator.settings.submitHandler ) {
if ( validator.submitButton ) {
// Insert a hidden input as a replacement for the missing submit button
hidden = $( "<input type='hidden'/>" )
.attr( "name", validator.submitButton.name )
.val( $( validator.submitButton ).val() )
.appendTo( validator.currentForm );
}
// Insert a hidden input as a replacement for the missing submit button
// The hidden input is inserted in two cases:
// - A user defined a `submitHandler`
// - There was a pending request due to `remote` method and `stopRequest()`
// was called to submit the form in case it's valid
if ( validator.submitButton && ( validator.settings.submitHandler || validator.formSubmitted ) ) {
hidden = $( "<input type='hidden'/>" )
.attr( "name", validator.submitButton.name )
.val( $( validator.submitButton ).val() )
.appendTo( validator.currentForm );
}
if ( validator.settings.submitHandler ) {
result = validator.settings.submitHandler.call( validator, validator.currentForm, event );
if ( validator.submitButton ) {
if ( hidden ) {
// And clean up afterwards; thanks to no-block-scope, hidden can be referenced
hidden.remove();
@ -112,7 +118,7 @@ $.extend( $.fn, {
return validator;
},
// http://jqueryvalidation.org/valid/
// https://jqueryvalidation.org/valid/
valid: function() {
var valid, validator, errorList;
@ -133,13 +139,22 @@ $.extend( $.fn, {
return valid;
},
// http://jqueryvalidation.org/rules/
// https://jqueryvalidation.org/rules/
rules: function( command, argument ) {
var element = this[ 0 ],
settings, staticRules, existingRules, data, param, filtered;
// If nothing is selected, return empty object; can't chain anyway
if ( element == null || element.form == null ) {
if ( element == null ) {
return;
}
if ( !element.form && element.hasAttribute( "contenteditable" ) ) {
element.form = this.closest( "form" )[ 0 ];
element.name = this.attr( "name" );
}
if ( element.form == null ) {
return;
}
@ -167,9 +182,6 @@ $.extend( $.fn, {
$.each( argument.split( /\s/ ), function( index, method ) {
filtered[ method ] = existingRules[ method ];
delete existingRules[ method ];
if ( method === "required" ) {
$( element ).removeAttr( "aria-required" );
}
} );
return filtered;
}
@ -189,7 +201,6 @@ $.extend( $.fn, {
param = data.required;
delete data.required;
data = $.extend( { required: param }, data );
$( element ).attr( "aria-required", "true" );
}
// Make sure remote is at back
@ -206,18 +217,18 @@ $.extend( $.fn, {
// Custom selectors
$.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables backwards compatibility to jQuery 1.7. Can be removed when dropping jQ 1.7.x support
// http://jqueryvalidation.org/blank-selector/
// https://jqueryvalidation.org/blank-selector/
blank: function( a ) {
return !$.trim( "" + $( a ).val() );
},
// http://jqueryvalidation.org/filled-selector/
// https://jqueryvalidation.org/filled-selector/
filled: function( a ) {
var val = $( a ).val();
return val !== null && !!$.trim( "" + val );
},
// http://jqueryvalidation.org/unchecked-selector/
// https://jqueryvalidation.org/unchecked-selector/
unchecked: function( a ) {
return !$( a ).prop( "checked" );
}
@ -230,7 +241,7 @@ $.validator = function( options, form ) {
this.init();
};
// http://jqueryvalidation.org/jQuery.validator.format/
// https://jqueryvalidation.org/jQuery.validator.format/
$.validator.format = function( source, params ) {
if ( arguments.length === 1 ) {
return function() {
@ -343,7 +354,7 @@ $.extend( $.validator, {
}
},
// http://jqueryvalidation.org/jQuery.validator.setDefaults/
// https://jqueryvalidation.org/jQuery.validator.setDefaults/
setDefaults: function( settings ) {
$.extend( $.validator.defaults, settings );
},
@ -402,6 +413,7 @@ $.extend( $.validator, {
// Set form expando on contenteditable
if ( !this.form && this.hasAttribute( "contenteditable" ) ) {
this.form = $( this ).closest( "form" )[ 0 ];
this.name = $( this ).attr( "name" );
}
var validator = $.data( this.form, "validator" ),
@ -426,13 +438,9 @@ $.extend( $.validator, {
if ( this.settings.invalidHandler ) {
$( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler );
}
// Add aria-required to any Static/Data/Class required fields before first validation
// Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html
$( this.currentForm ).find( "[required], [data-rule-required], .required" ).attr( "aria-required", "true" );
},
// http://jqueryvalidation.org/Validator.form/
// https://jqueryvalidation.org/Validator.form/
form: function() {
this.checkForm();
$.extend( this.submitted, this.errorMap );
@ -452,7 +460,7 @@ $.extend( $.validator, {
return this.valid();
},
// http://jqueryvalidation.org/Validator.element/
// https://jqueryvalidation.org/Validator.element/
element: function( element ) {
var cleanElement = this.clean( element ),
checkElement = this.validationTargetFor( cleanElement ),
@ -503,7 +511,7 @@ $.extend( $.validator, {
return result;
},
// http://jqueryvalidation.org/Validator.showErrors/
// https://jqueryvalidation.org/Validator.showErrors/
showErrors: function( errors ) {
if ( errors ) {
var validator = this;
@ -529,7 +537,7 @@ $.extend( $.validator, {
}
},
// http://jqueryvalidation.org/Validator.resetForm/
// https://jqueryvalidation.org/Validator.resetForm/
resetForm: function() {
if ( $.fn.resetForm ) {
$( this.currentForm ).resetForm();
@ -570,7 +578,10 @@ $.extend( $.validator, {
var count = 0,
i;
for ( i in obj ) {
if ( obj[ i ] ) {
// This check allows counting elements with empty error
// message as invalid elements
if ( obj[ i ] !== undefined && obj[ i ] !== null && obj[ i ] !== false ) {
count++;
}
}
@ -635,6 +646,7 @@ $.extend( $.validator, {
// Set form expando on contenteditable
if ( this.hasAttribute( "contenteditable" ) ) {
this.form = $( this ).closest( "form" )[ 0 ];
this.name = name;
}
// Select only the first element for each name, and only those with rules specified
@ -735,21 +747,27 @@ $.extend( $.validator, {
} ).length,
dependencyMismatch = false,
val = this.elementValue( element ),
result, method, rule;
result, method, rule, normalizer;
// If a normalizer is defined for this element, then
// call it to retreive the changed value instead
// Prioritize the local normalizer defined for this element over the global one
// if the former exists, otherwise user the global one in case it exists.
if ( typeof rules.normalizer === "function" ) {
normalizer = rules.normalizer;
} else if ( typeof this.settings.normalizer === "function" ) {
normalizer = this.settings.normalizer;
}
// If normalizer is defined, then call it to retreive the changed value instead
// of using the real one.
// Note that `this` in the normalizer is `element`.
if ( typeof rules.normalizer === "function" ) {
val = rules.normalizer.call( element, val );
if ( normalizer ) {
val = normalizer.call( element, val );
if ( typeof val !== "string" ) {
throw new TypeError( "The normalizer should return a string value." );
}
// Delete the normalizer from rules to avoid treating
// it as a pre-defined method.
// Delete the normalizer from rules to avoid treating it as a pre-defined method.
delete rules.normalizer;
}
@ -1089,6 +1107,15 @@ $.extend( $.validator, {
$( element ).removeClass( this.settings.pendingClass );
if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
$( this.currentForm ).submit();
// Remove the hidden input that was used as a replacement for the
// missing submit button. The hidden input is added by `handle()`
// to ensure that the value of the used submit button is passed on
// for scripted submits triggered by this method
if ( this.submitButton ) {
$( "input:hidden[name='" + this.submitButton.name + "']", this.currentForm ).remove();
}
this.formSubmitted = false;
} else if ( !valid && this.pendingRequest === 0 && this.formSubmitted ) {
$( this.currentForm ).triggerHandler( "invalid-form", [ this ] );
@ -1316,7 +1343,7 @@ $.extend( $.validator, {
return data;
},
// http://jqueryvalidation.org/jQuery.validator.addMethod/
// https://jqueryvalidation.org/jQuery.validator.addMethod/
addMethod: function( name, method, message ) {
$.validator.methods[ name ] = method;
$.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ];
@ -1325,10 +1352,10 @@ $.extend( $.validator, {
}
},
// http://jqueryvalidation.org/jQuery.validator.methods/
// https://jqueryvalidation.org/jQuery.validator.methods/
methods: {
// http://jqueryvalidation.org/required-method/
// https://jqueryvalidation.org/required-method/
required: function( value, element, param ) {
// Check if dependency is met
@ -1347,7 +1374,7 @@ $.extend( $.validator, {
return value.length > 0;
},
// http://jqueryvalidation.org/email-method/
// https://jqueryvalidation.org/email-method/
email: function( value, element ) {
// From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
@ -1357,7 +1384,7 @@ $.extend( $.validator, {
return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value );
},
// http://jqueryvalidation.org/url-method/
// https://jqueryvalidation.org/url-method/
url: function( value, element ) {
// Copyright (c) 2010-2013 Diego Perini, MIT licensed
@ -1367,60 +1394,60 @@ $.extend( $.validator, {
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
},
// http://jqueryvalidation.org/date-method/
// https://jqueryvalidation.org/date-method/
date: function( value, element ) {
return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() );
},
// http://jqueryvalidation.org/dateISO-method/
// https://jqueryvalidation.org/dateISO-method/
dateISO: function( value, element ) {
return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value );
},
// http://jqueryvalidation.org/number-method/
// https://jqueryvalidation.org/number-method/
number: function( value, element ) {
return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value );
},
// http://jqueryvalidation.org/digits-method/
// https://jqueryvalidation.org/digits-method/
digits: function( value, element ) {
return this.optional( element ) || /^\d+$/.test( value );
},
// http://jqueryvalidation.org/minlength-method/
// https://jqueryvalidation.org/minlength-method/
minlength: function( value, element, param ) {
var length = $.isArray( value ) ? value.length : this.getLength( value, element );
return this.optional( element ) || length >= param;
},
// http://jqueryvalidation.org/maxlength-method/
// https://jqueryvalidation.org/maxlength-method/
maxlength: function( value, element, param ) {
var length = $.isArray( value ) ? value.length : this.getLength( value, element );
return this.optional( element ) || length <= param;
},
// http://jqueryvalidation.org/rangelength-method/
// https://jqueryvalidation.org/rangelength-method/
rangelength: function( value, element, param ) {
var length = $.isArray( value ) ? value.length : this.getLength( value, element );
return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
},
// http://jqueryvalidation.org/min-method/
// https://jqueryvalidation.org/min-method/
min: function( value, element, param ) {
return this.optional( element ) || value >= param;
},
// http://jqueryvalidation.org/max-method/
// https://jqueryvalidation.org/max-method/
max: function( value, element, param ) {
return this.optional( element ) || value <= param;
},
// http://jqueryvalidation.org/range-method/
// https://jqueryvalidation.org/range-method/
range: function( value, element, param ) {
return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] );
},
// http://jqueryvalidation.org/step-method/
// https://jqueryvalidation.org/step-method/
step: function( value, element, param ) {
var type = $( element ).attr( "type" ),
errorMessage = "Step attribute on input type " + type + " is not supported.",
@ -1458,7 +1485,7 @@ $.extend( $.validator, {
return this.optional( element ) || valid;
},
// http://jqueryvalidation.org/equalTo-method/
// https://jqueryvalidation.org/equalTo-method/
equalTo: function( value, element, param ) {
// Bind to the blur event of the target in order to revalidate whenever the target field is updated
@ -1471,7 +1498,7 @@ $.extend( $.validator, {
return value === target.val();
},
// http://jqueryvalidation.org/remote-method/
// https://jqueryvalidation.org/remote-method/
remote: function( value, element, param, method ) {
if ( this.optional( element ) ) {
return "dependency-mismatch";

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -53,12 +53,10 @@
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="IRCSharp, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IRCSharp.1.0.0.1\lib\net462\IRCSharp.dll</HintPath>
@ -76,41 +74,34 @@
<HintPath>..\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.1\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.AspNet.SignalR.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.2.2.1\lib\net45\Microsoft.AspNet.SignalR.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.AspNet.SignalR.Core, Version=2.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.SignalR.Core.2.2.2\lib\net45\Microsoft.AspNet.SignalR.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.SignalR.SystemWeb, Version=2.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.SignalR.SystemWeb.2.2.1\lib\net45\Microsoft.AspNet.SignalR.SystemWeb.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.AspNet.SignalR.SystemWeb, Version=2.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.SignalR.SystemWeb.2.2.2\lib\net45\Microsoft.AspNet.SignalR.SystemWeb.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.2.0.4\lib\net45\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Owin, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.3.1.0\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.1.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Owin.Security, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Security.3.1.0\lib\net45\Microsoft.Owin.Security.dll</HintPath>
</Reference>
<Reference Include="Mime-Detective, Version=0.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Mime-Detective.0.0.5\lib\net45\Mime-Detective.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll</HintPath>
<Private>True</Private>
<Reference Include="MySql.Data, Version=6.10.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.6.10.6\lib\net452\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="NBitcoin, Version=3.0.2.10, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NBitcoin.3.0.2.10\lib\net45\NBitcoin.dll</HintPath>
@ -121,16 +112,14 @@
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Piwik.Tracker, Version=2.16.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Piwik.Tracker.2.16.0.0\lib\net40\Piwik.Tracker.dll</HintPath>
<Private>True</Private>
<Reference Include="Piwik.Tracker, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Piwik.Tracker.3.0.0\lib\net40\Piwik.Tracker.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="QRCoder, Version=1.2.3.0, Culture=neutral, processorArchitecture=MSIL">
@ -138,12 +127,18 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
@ -523,6 +518,17 @@
<Content Include="Content\Highlight\xcode.css" />
<Content Include="Content\Highlight\zenburn.css" />
<Content Include="Content\jquery.tocify.css" />
<Content Include="docs\MySqlCommand.xml" />
<Content Include="docs\MySqlCommandBuilder.xml" />
<Content Include="docs\MySqlConnection.xml" />
<Content Include="docs\MySqlConnectionStringBuilder.xml" />
<Content Include="docs\MySqlDataAdapter.xml" />
<Content Include="docs\MySqlDataReader.xml" />
<Content Include="docs\MySqlException.xml" />
<Content Include="docs\MySqlHelper.xml" />
<Content Include="docs\MySqlParameter.xml" />
<Content Include="docs\MySqlParameterCollection.xml" />
<Content Include="docs\MySqlTransaction.xml" />
<Content Include="Fonts\fontawesome-webfont.svg" />
<Content Include="Fonts\glyphicons-halflings-regular.svg" />
<Content Include="Images\redbubble_icon.png" />
@ -716,16 +722,17 @@
<Content Include="Scripts\Highcharts\highcharts.js" />
<Content Include="Scripts\Highlight\highlight.pack.js" />
<None Include="Scripts\jquery-3.1.1.intellisense.js" />
<Content Include="Scripts\jquery-3.1.1.js" />
<Content Include="Scripts\jquery-3.1.1.min.js" />
<Content Include="Scripts\jquery-3.1.1.slim.js" />
<Content Include="Scripts\jquery-3.1.1.slim.min.js" />
<None Include="Scripts\jquery-3.3.1.intellisense.js" />
<Content Include="Scripts\jquery-3.3.1.js" />
<Content Include="Scripts\jquery-3.3.1.min.js" />
<Content Include="Scripts\jquery-3.3.1.slim.js" />
<Content Include="Scripts\jquery-3.3.1.slim.min.js" />
<Content Include="Scripts\jquery-ui.widgets.js" />
<Content Include="Scripts\jquery.blockUI.js" />
<Content Include="Scripts\jquery.fileupload.js" />
<Content Include="Scripts\jquery.iframe-transport.js" />
<Content Include="Scripts\jquery.signalR-2.2.1.js" />
<Content Include="Scripts\jquery.signalR-2.2.1.min.js" />
<Content Include="Scripts\jquery.signalR-2.2.2.js" />
<Content Include="Scripts\jquery.signalR-2.2.2.min.js" />
<Content Include="Scripts\jquery.tocify.min.js" />
<None Include="Scripts\jquery.validate-vsdoc.js" />
<Content Include="Scripts\jquery.validate.js" />
@ -769,8 +776,8 @@
<Content Include="Areas\User\Views\User\Register.cshtml" />
<Content Include="Areas\Dev\Views\Dev\Index.cshtml" />
<Content Include="Areas\User\Views\User\_LoginModalPartial.cshtml" />
<Content Include="Scripts\jquery-3.1.1.slim.min.map" />
<Content Include="Scripts\jquery-3.1.1.min.map" />
<Content Include="Scripts\jquery-3.3.1.slim.min.map" />
<Content Include="Scripts\jquery-3.3.1.min.map" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\About\Models\" />
@ -899,8 +906,8 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
@ -6,7 +6,7 @@
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings configSource="App_Data\ConnectionStrings.config" />
<!-- Create ConnectionStrings.config and add your connection string node-->
<!--
@ -135,7 +135,7 @@
<add name="Access-Control-Allow-Headers" value="Authorization, Accept, Origin, Content-Type, X-Requested-With, Connection, Transfer-Encoding" />
<add name="strict-transport-security" value="max-age=31536000; includeSubdomains; preload" />
<add name="X-XSS-Protection" value="1; mode=block" />
<add name="Vary" value="Origin"/>
<add name="Vary" value="Origin" />
</customHeaders>
</httpProtocol>
<httpErrors errorMode="Detailed" />
@ -172,11 +172,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
@ -190,16 +190,16 @@
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.data>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
<add description=".Net Framework Data Provider for MySQL" invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

View File

@ -0,0 +1,934 @@
<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>
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>
Using the '@' symbol for paramters is now the preferred approach although the old pattern of using
'?' is still supported. Please be aware though that using '@' can cause conflicts when user variables
are also used. To help with this situation please see the documentation on the 'allow user variables'
connection string option. The 'old syntax' connection string option has now been deprecated.
</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="vbnet">
Public Sub InsertRow(myConnectionString As String)
&quot; 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="vbnet">
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>
<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="vbnet">
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.
<code lang="vbnet">
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>
<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.
<code lang="vbnet">
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>
</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.
<code lang="vbnet">
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>
<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="vbnet">
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="vbnet">
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())
{
Console.WriteLine(myReader.GetString(0));
}
}
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="VB.NET">
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>
<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>
</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="vbnet">
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-&gt;Connection-&gt;Open();
myCommand-&gt;ExecuteScalar();
myConnection-&gt;Close();
}
</code>
</example>
</ExecuteScalar>
<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. Starting with Connector/Net 5.0, having both a stored function
and stored procedure with the same name in the same database is not supported. It is
suggested that you provide unqiue names for your stored routines.
</para>
</remarks>
<example>
The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
<code lang="vbnet">
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>
<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 30
seconds.
</value>
<remarks>
CommandTimeout is dependent on the ability of MySQL to cancel an executing query.
Because of this, CommandTimeout is only supported when connected to MySQL
version 5.0.0 or higher.
</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="vbnet">
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="vbnet">
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>
<LastInsertedId>
<summary>Provides the id of the last inserted row.</summary>
<value>
Id of the last inserted row. -1 if none exists.
</value>
<remarks>
An important point to remember is that this property can be used
in batch SQL scenarios but it's important to remember that it will
only reflect the insert id from the last insert statement in the batch.
This property can also be used when the batch includes select statements
and ExecuteReader is used. This property can be consulted during result set
processing.
</remarks>
</LastInsertedId>
<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="vbnet">
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() &amp; 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&lt;myParamArray.Length; j++)
{
myCommand.Parameters.Add(myParamArray[j]) ;
}
string myMessage = "";
for (int i = 0; i &lt; 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>
<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>
</docs>

View File

@ -0,0 +1,321 @@
<docs>
<class>
<summary>
Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
</summary>
<remarks>
<para>
The <see cref="MySqlDataAdapter"/> does not automatically generate the SQL statements required to
reconcile changes made to a <see cref="System.Data.DataSet">DataSet</see> with the associated instance of MySQL.
However, you can create a <B>MySqlCommandBuilder</B> object to automatically generate SQL statements for
single-table updates if you set the <see cref="MySqlDataAdapter.SelectCommand">SelectCommand</see> property
of the <B>MySqlDataAdapter</B>. Then, any additional SQL statements that you do not set are generated by the
<B>MySqlCommandBuilder</B>.
</para>
<para>
The <B>MySqlCommandBuilder</B> registers itself as a listener for <see cref="MySqlDataAdapter.OnRowUpdating">RowUpdating</see>
events whenever you set the <see cref="DataAdapter"/> property. You can only associate one
<B>MySqlDataAdapter</B> or <B>MySqlCommandBuilder</B> object with each other at one time.
</para>
<para>
To generate INSERT, UPDATE, or DELETE statements, the <B>MySqlCommandBuilder</B> uses the
<B>SelectCommand</B> property to retrieve a required set of metadata automatically. If you change
the <B>SelectCommand</B> after the metadata has is retrieved (for example, after the first update), you
should call the <see cref="RefreshSchema"/> method to update the metadata.
</para>
<para>
The <B>SelectCommand</B> must also return at least one primary key or unique
column. If none are present, an <I>InvalidOperation</I> exception is generated,
and the commands are not generated.
</para>
<para>
The <B>MySqlCommandBuilder</B> also uses the <see cref="MySqlCommand.Connection">Connection</see>,
<see cref="MySqlCommand.CommandTimeout">CommandTimeout</see>, and <see cref="MySqlCommand.Transaction">Transaction</see>
properties referenced by the <B>SelectCommand</B>. The user should call
<B>RefreshSchema</B> if any of these properties are modified, or if the
<B>SelectCommand</B> itself is replaced. Otherwise the <see cref="MySqlDataAdapter.InsertCommand">InsertCommand</see>,
<see cref="MySqlDataAdapter.UpdateCommand">UpdateCommand</see>, and
<see cref="MySqlDataAdapter.DeleteCommand">DeleteCommand</see> properties retain
their previous values.
</para>
<para>
If you call <i>Dispose</i>, the <B>MySqlCommandBuilder</B> is disassociated
from the <B>MySqlDataAdapter</B>, and the generated commands are no longer used.
</para>
<note>
Caution must be used when using MySqlCOmmandBuilder on MySql 4.0 systems. With MySql 4.0,
database/schema information is not provided to the connector for a query. This means that
a query that pulls columns from two identically named tables in two or more different databases
will not cause an exception to be thrown but will not work correctly. Even more dangerous
is the situation where your select statement references database X but is executed in
database Y and both databases have tables with similar layouts. This situation can cause
unwanted changes or deletes.
This note does not apply to MySQL versions 4.1 and later.
</note>
</remarks>
<example>
The following example uses the <see cref="MySqlCommand"/>, along
<see cref="MySqlDataAdapter"/> and <see cref="MySqlConnection"/>, to
select rows from a data source. The example is passed an initialized
<see cref="System.Data.DataSet"/>, a connection string, a
query string that is a SQL SELECT statement, and a string that is the
name of the database table. The example then creates a <B>MySqlCommandBuilder</B>.
<code lang="vbnet">
Public Shared Function SelectRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet
Dim myConn As New MySqlConnection(myConnection)
Dim myDataAdapter As New MySqlDataAdapter()
myDataAdapter.SelectCommand = New MySqlCommand(mySelectQuery, myConn)
Dim cb As SqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter)
myConn.Open()
Dim ds As DataSet = New DataSet
myDataAdapter.Fill(ds, myTableName)
' Code to modify data in DataSet here
' Without the MySqlCommandBuilder this line would fail.
myDataAdapter.Update(ds, myTableName)
myConn.Close()
End Function 'SelectRows
</code>
<code lang="C#">
public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName)
{
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
myConn.Open();
DataSet ds = new DataSet();
myDataAdapter.Fill(ds, myTableName);
//code to modify data in DataSet here
//Without the MySqlCommandBuilder this line would fail
myDataAdapter.Update(ds, myTableName);
myConn.Close();
return ds;
}
</code>
</example>
</class>
<Ctor>
<summary>
Initializes a new instance of the <see cref="MySqlCommandBuilder"/> class.
</summary>
</Ctor>
<Ctor2>
<summary>
Initializes a new instance of the <see cref="MySqlCommandBuilder"/> class
with the associated <see cref="MySqlDataAdapter"/> object.
</summary>
<param name="adapter">
The <see cref="MySqlDataAdapter"/> to use.
</param>
<remarks>
<para>
The <see cref="MySqlCommandBuilder"/> registers itself as a listener for
<see cref="MySqlDataAdapter.RowUpdating"/> events that are generated by the
<see cref="MySqlDataAdapter"/> specified in this property.
</para>
<para>
When you create a new instance <B>MySqlCommandBuilder</B>, any existing
<B>MySqlCommandBuilder</B> associated with this <B>MySqlDataAdapter</B>
is released.
</para>
</remarks>
</Ctor2>
<DataAdapter>
<summary>
Gets or sets a <see cref="MySqlDataAdapter"/> object for which SQL statements are automatically generated.
</summary>
<value>
A <see cref="MySqlDataAdapter"/> object.
</value>
<remarks>
<para>
The <see cref="MySqlCommandBuilder"/> registers itself as a listener for
<see cref="MySqlDataAdapter.RowUpdating"/> events that are generated by the
<see cref="MySqlDataAdapter"/> specified in this property.
</para>
<para>
When you create a new instance <B>MySqlCommandBuilder</B>, any existing
<B>MySqlCommandBuilder</B> associated with this <B>MySqlDataAdapter</B>
is released.
</para>
</remarks>
</DataAdapter>
<QuotePrefix>
<summary>
Gets or sets the beginning character or characters to use when specifying MySQL
database objects (for example, tables or columns) whose names contain
characters such as spaces or reserved tokens.
</summary>
<value>
The beginning character or characters to use. The default value is `.
</value>
<remarks>
Database objects in MySQL can contain special characters such as spaces that would
make normal SQL strings impossible to correctly parse. Use of the <b>QuotePrefix</b>
and the <see cref="QuoteSuffix"/> properties allows the <see cref="MySqlCommandBuilder"/>
to build SQL commands that handle this situation.
</remarks>
</QuotePrefix>
<QuoteSuffix>
<summary>
Gets or sets the beginning character or characters to use when specifying MySQL
database objects (for example, tables or columns) whose names contain
characters such as spaces or reserved tokens.
</summary>
<value>
The beginning character or characters to use. The default value is `.
</value>
<remarks>
Database objects in MySQL can contain special characters such as spaces that would
make normal SQL strings impossible to correctly parse. Use of the <see cref="QuotePrefix"/>
and the <b>QuoteSuffix</b> properties allows the <see cref="MySqlCommandBuilder"/>
to build SQL commands that handle this situation.
</remarks>
</QuoteSuffix>
<DeriveParameters>
<summary>
</summary>
<remarks>
</remarks>
</DeriveParameters>
<GetDeleteCommand>
<summary>
Gets the automatically generated <see cref="MySqlCommand"/> object
required to perform deletions on the database.
</summary>
<returns>
The <see cref="MySqlCommand"/> object generated to handle delete operations.
</returns>
<remarks>
<para>
An application can use the <B>GetDeleteCommand</B> method for informational
or troubleshooting purposes because it returns the <see cref="MySqlCommand"/>
object to be executed.
</para>
<para>
You can also use <B>GetDeleteCommand</B> as the basis of a modified command.
For example, you might call <B>GetDeleteCommand</B> and modify the
<see cref="MySqlCommand.CommandTimeout"/> value, and then explicitly set that on the
<see cref="MySqlDataAdapter"/>.
</para>
<para>
After the SQL statement is first generated, the application must explicitly
call <see cref="RefreshSchema"/> if it changes the statement in any way.
Otherwise, the <B>GetDeleteCommand</B> will be still be using information
from the previous statement, which might not be correct. The SQL statements
are first generated either when the application calls
<see cref="System.Data.Common.DataAdapter.Update"/> or <B>GetDeleteCommand</B>.
</para>
</remarks>
</GetDeleteCommand>
<GetInsertCommand>
<summary>
Gets the automatically generated <see cref="MySqlCommand"/> object
required to perform insertions on the database.
</summary>
<returns>
The <see cref="MySqlCommand"/> object generated to handle insert operations.
</returns>
<remarks>
<para>
An application can use the <B>GetInsertCommand</B> method for informational
or troubleshooting purposes because it returns the <see cref="MySqlCommand"/>
object to be executed.
</para>
<para>
You can also use the <B>GetInsertCommand</B> as the basis of a modified command.
For example, you might call <B>GetInsertCommand</B> and modify the
<see cref="MySqlCommand.CommandTimeout"/> value, and then explicitly set that on the
<see cref="MySqlDataAdapter"/>.
</para>
<para>
After the SQL statement is first generated, the application must explicitly
call <see cref="RefreshSchema"/> if it changes the statement in any way.
Otherwise, the <B>GetInsertCommand</B> will be still be using information
from the previous statement, which might not be correct. The SQL statements
are first generated either when the application calls
<see cref="System.Data.Common.DataAdapter.Update"/> or <B>GetInsertCommand</B>.
</para>
</remarks>
</GetInsertCommand>
<GetUpdateCommand>
<summary>
Gets the automatically generated <see cref="MySqlCommand"/> object
required to perform updates on the database.
</summary>
<returns>
The <see cref="MySqlCommand"/> object generated to handle update operations.
</returns>
<remarks>
<para>
An application can use the <B>GetUpdateCommand</B> method for informational
or troubleshooting purposes because it returns the <see cref="MySqlCommand"/>
object to be executed.
</para>
<para>
You can also use <B>GetUpdateCommand</B> as the basis of a modified command.
For example, you might call <B>GetUpdateCommand</B> and modify the
<see cref="MySqlCommand.CommandTimeout"/> value, and then explicitly set that on the
<see cref="MySqlDataAdapter"/>.
</para>
<para>
After the SQL statement is first generated, the application must explicitly
call <see cref="RefreshSchema"/> if it changes the statement in any way.
Otherwise, the <B>GetUpdateCommand</B> will be still be using information
from the previous statement, which might not be correct. The SQL statements
are first generated either when the application calls
<see cref="System.Data.Common.DataAdapter.Update"/> or <B>GetUpdateCommand</B>.
</para>
</remarks>
</GetUpdateCommand>
<RefreshSchema>
<summary>
Refreshes the database schema information used to generate INSERT, UPDATE, or
DELETE statements.
</summary>
<remarks>
<para>
An application should call <B>RefreshSchema</B> whenever the SELECT statement
associated with the <see cref="MySqlCommandBuilder"/> changes.
</para>
<para>
An application should call <B>RefreshSchema</B> whenever the
<see cref="MySqlDataAdapter.SelectCommand"/> value of the <see cref="MySqlDataAdapter"/> changes.
</para>
</remarks>
</RefreshSchema>
</docs>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
<docs>
<Server>
<summary>
Gets or sets the name or address of the MySQL instance to connect to.
</summary>
<remarks>
If this property is not set, then the provider will attempt to
connect to <b>localhost</b> even though this property will return
<b>String.Empty</b>.
</remarks>
<example>
</example>
</Server>
<Database>
<summary>
Gets or sets the name of the database that should be selected
when the connection is first opened.
</summary>
<remarks>
There is no default for this property and, if not set, the
connection will not have a current database until one is set
using the <see cref="ChangeDatabase"/> method.
</remarks>
<example>
</example>
</Database>
<ConnectionProtocol>
<summary>
Gets or sets the connection protocol that is being used for this
connection.
</summary>
<remarks>
</remarks>
<example>
</example>
</ConnectionProtocol>
<PipeName>
<summary>
Gets or sets the name of the named pipe object that the provider
should use.
</summary>
<remarks>
This property has no effect unless the <see cref="ConnectionProtocol"/>
property has been set to <b>NamedPipe</b>.
</remarks>
<example>
</example>
</PipeName>
</docs>

View File

@ -0,0 +1,801 @@
<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(DataSet)"/>, which changes the data in the
<B>DataSet</B> to match the data in the data source, and <see cref="System.Data.Common.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(DataTable, 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 allows only
Int16, Int32, and Int64 to have the AutoIncrement property set.
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="vbnet">
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="vbnet">
Public Sub CreateSqlDataAdapter()
Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" &amp; _
"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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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);
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;
}
</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="vbnet">
Public Sub CreateSqlDataAdapter()
Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" &amp; _
"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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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.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;
}
</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(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="vbnet">
Public Sub CreateSqlDataAdapter()
Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" &amp; _
"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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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.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;
}
</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="vbnet">
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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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.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;
}
</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.DbDataAdapter.Update(System.Data.DataSet)"/> 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.DbDataAdapter.Update(System.Data.DataSet)"/>, 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="vbnet">
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 DeleteCommand.
cmd = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn)
parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id")
parm.SourceVersion = DataRowVersion.Original
da.DeleteCommand = 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 DeleteCommand.
cmd = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn);
parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id");
parm.SourceVersion = DataRowVersion.Original;
da.DeleteCommand = cmd;
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.DbDataAdapter.Update(System.Data.DataSet)"/> 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.DbDataAdapter.Update(System.Data.DataSet)"/>, 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="vbnet">
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>
</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.DbDataAdapter.Update(System.Data.DataSet)"/> to update records in the
database with data from the <see cref="DataSet"/>.
</value>
<remarks>
<para>
During <see cref="System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)"/>, 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="vbnet">
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="vbnet">
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>

View File

@ -0,0 +1,452 @@
<docs>
<ClassSummary>
<summary>
Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
</summary>
<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="vbnet">
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) &amp; ", " &amp; 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>
<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>
<overloads/>
<summary>
Gets the value of the specified column as a <see cref="TimeSpan"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Time</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
<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(int)"/>.
</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="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetDateTime>
<GetDateTimeS>
<summary>
Gets the value of the specified column as a <see cref="DateTime"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
<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(int)"/>.
</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="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetDateTimeS>
<GetMySqlDateTime>
<summary>
Gets the value of the specified column as a <see cref="MySql.Data.Types.MySqlDateTime"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>String</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetString>
<GetStringS>
<summary>
Gets the value of the specified column as a <see cref="String"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>String</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetStringS>
<GetDecimal>
<summary>
Gets the value of the specified column as a <see cref="Decimal"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Decimal</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal</param>
<returns>The value of the specified column.</returns>
</GetDecimal>
<GetDecimalS>
<summary>
Gets the value of the specified column as a <see cref="Decimal"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Decimal</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetDecimalS>
<GetDouble>
<summary>Gets the value of the specified column as a double-precision floating point number.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Double</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetDouble>
<GetDoubleS>
<summary>Gets the value of the specified column as a double-precision floating point number.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Double</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetDoubleS>
<GetFloat>
<summary>
Gets the value of the specified column as a single-precision floating point number.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Float</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetFloat>
<GetFloatS>
<summary>
Gets the value of the specified column as a single-precision floating point number.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Float</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetFloatS>
<GetGiud>
<summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetGiud>
<GetGiudS>
<summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetGiudS>
<GetInt16>
<summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>16 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetInt16>
<GetInt16S>
<summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; threfore, the data retrieved must already be a <b>16 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetInt16S>
<GetInt32>
<summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>32 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetInt32>
<GetInt32S>
<summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>32 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetInt32S>
<GetInt64>
<summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>64 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetInt64>
<GetInt64S>
<summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>64 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetInt64S>
<GetUInt16>
<summary>Gets the value of the specified column as a 16-bit unsigned integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>16 bit unsigned integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>32 bit unsigned integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>64 bit unsigned integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</param>
<returns>The value of the specified column.</returns>
</GetUInt64>
</docs>

View File

@ -0,0 +1,53 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
<para>
This class is created whenever the MySql Data Provider encounters an error generated from the server.
</para>
<para>
Any open connections are not automatically closed when an exception is thrown. If
the client application determines that the exception is fatal, it should close any open
<see cref="MySqlDataReader"/> objects or <see cref="MySqlConnection"/> objects.
</para>
</remarks>
<example>
The following example generates a <B>MySqlException</B> due to a missing server,
and then displays the exception.
<code lang="vbnet">
Public Sub ShowException()
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;")
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch e As MySqlException
MessageBox.Show( e.Message )
End Try
End Sub
</code>
<code lang="C#">
public void ShowException()
{
string mySelectQuery = "SELECT column1 FROM table1";
MySqlConnection myConnection =
new MySqlConnection("Data Source=localhost;Database=Sample;");
MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (MySqlException e)
{
MessageBox.Show( e.Message );
}
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,53 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
<para>
This class is created whenever the MySql Data Provider encounters an error generated from the server.
</para>
<para>
Any open connections are not automatically closed when an exception is thrown. If
the client application determines that the exception is fatal, it should close any open
<see cref="MySqlDataReader"/> objects or <see cref="MySqlConnection"/> objects.
</para>
</remarks>
<example>
The following example generates a <B>MySqlException</B> due to a missing server,
and then displays the exception.
<code lang="vbnet">
Public Sub ShowException()
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;")
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch e As MySqlException
MessageBox.Show( e.Message )
End Try
End Sub
</code>
<code lang="C#">
public void ShowException()
{
string mySelectQuery = "SELECT column1 FROM table1";
MySqlConnection myConnection =
new MySqlConnection("Data Source=localhost;Database=Sample;");
MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (MySqlException e)
{
MessageBox.Show( e.Message );
}
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,45 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
Parameter names are not case sensitive.
</remarks>
<example>
The following example creates multiple instances of <B>MySqlParameter</B> through the
<see cref="MySqlParameterCollection"/> collection within the <see cref="MySqlDataAdapter"/>.
These parameters are used to select data from the data source and place the data
in the <see cref="DataSet"/>. This example assumes that a <B>DataSet</B> and a
<B>MySqlDataAdapter</B> have already been created with the appropriate schema, commands,
and connection.
<code lang="vbnet">
Public Sub AddSqlParameters()
' ...
' create myDataSet and myDataAdapter
' ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239
myDataAdapter.Fill(myDataSet)
End Sub 'AddSqlParameters
</code>
<code lang="C#">
public void AddSqlParameters()
{
// ...
// create myDataSet and myDataAdapter
// ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;
myDataAdapter.Fill(myDataSet);
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,45 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
The number of the parameters in the collection must be equal to the number of
parameter placeholders within the command text, or an exception will be generated.
</remarks>
<example>
The following example creates multiple instances of <see cref="MySqlParameter"/>
through the <B>MySqlParameterCollection</B> collection within the <see cref="MySqlDataAdapter"/>.
These parameters are used to select data within the data source and place the data in
the <see cref="System.Data.DataSet"/>. This code assumes that a <B>DataSet</B> and a <B>MySqlDataAdapter</B>
have already been created with the appropriate schema, commands, and connection.
<code lang="vbnet">
Public Sub AddParameters()
' ...
' create myDataSet and myDataAdapter
' ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239
myDataAdapter.Fill(myDataSet)
End Sub 'AddSqlParameters
</code>
<code lang="C#">
public void AddSqlParameters()
{
// ...
// create myDataSet and myDataAdapter
// ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;
myDataAdapter.Fill(myDataSet);
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,329 @@
<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="vbnet">
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 " &amp; ex.GetType().ToString() &amp; _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _
"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 a <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="vbnet">
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 " &amp; ex.GetType().ToString() &amp; _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _
"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>
</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 a <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="vbnet">
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 " &amp; ex.GetType().ToString() &amp; _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _
"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>

View File

@ -4,12 +4,12 @@
<package id="bootstrap" version="3.3.7" targetFramework="net452" userInstalled="true" />
<package id="Bootstrap.Flat" version="3.3.4" targetFramework="net452" />
<package id="Bootstrap.Switch" version="3.3.2.1" targetFramework="net452" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" userInstalled="true" />
<package id="EntityFramework" version="6.2.0" targetFramework="net462" userInstalled="true" />
<package id="FontAwesome" version="4.7.0" targetFramework="net462" userInstalled="true" />
<package id="GitVersionTask" version="3.6.5" targetFramework="net462" developmentDependency="true" />
<package id="IRCSharp" version="1.0.0.1" targetFramework="net462" />
<package id="jQuery" version="3.1.1" targetFramework="net452" userInstalled="true" />
<package id="jQuery.Validation" version="1.16.0" targetFramework="net462" userInstalled="true" />
<package id="jQuery" version="3.3.1" targetFramework="net462" userInstalled="true" />
<package id="jQuery.Validation" version="1.17.0" targetFramework="net462" userInstalled="true" />
<package id="MarkdownDeep.Full" version="1.5" targetFramework="net452" />
<package id="MarkdownDeep.NET" version="1.5" targetFramework="net452" />
<package id="MarkdownHelper" version="1.3" targetFramework="net452" />
@ -17,28 +17,28 @@
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net452" userInstalled="true" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46" userInstalled="true" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46" userInstalled="true" />
<package id="Microsoft.AspNet.SignalR" version="2.2.1" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.2.1" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.2.1" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.1" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR" version="2.2.2" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.2.2" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.2.2" targetFramework="net462" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.2" targetFramework="net462" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net46" userInstalled="true" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net46" userInstalled="true" />
<package id="Microsoft.Azure.KeyVault.Core" version="2.0.4" targetFramework="net462" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net462" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net46" userInstalled="true" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net462" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net462" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net462" />
<package id="Microsoft.Net.Compilers" version="2.6.1" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net462" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net462" />
<package id="Microsoft.Owin.Security" version="3.1.0" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" userInstalled="true" />
<package id="Mime-Detective" version="0.0.5" targetFramework="net462" />
<package id="Modernizr" version="2.8.3" targetFramework="net452" userInstalled="true" />
<package id="MySql.Data" version="6.9.9" targetFramework="net452" />
<package id="MySql.Data" version="6.10.6" targetFramework="net462" />
<package id="NBitcoin" version="3.0.2.10" targetFramework="net462" />
<package id="nClam" version="2.0.6.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net462" userInstalled="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net462" userInstalled="true" />
<package id="Owin" version="1.0" targetFramework="net462" />
<package id="Piwik.Tracker" version="2.16.0.0" targetFramework="net452" />
<package id="Piwik.Tracker" version="3.0.0" targetFramework="net462" />
<package id="QRCoder" version="1.2.3" targetFramework="net462" />
<package id="Respond" version="1.4.2" targetFramework="net452" userInstalled="true" />
<package id="System.Xml.XmlSerializer" version="4.3.0" targetFramework="net462" />

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
@ -21,7 +21,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
@ -29,7 +29,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />

View File

@ -34,12 +34,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Media, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\net7mma.0.111192.1\lib\net452\Media.dll</HintPath>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net462" />
<package id="EntityFramework" version="6.2.0" targetFramework="net462" />
<package id="net7mma" version="0.111192.1" targetFramework="net462" />
</packages>

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props" Condition="Exists('..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props')" />
<Import Project="..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props" Condition="Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props')" />
<Import Project="..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props" Condition="Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" />
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -46,17 +48,14 @@
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -65,14 +64,23 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\xunit.analyzers.0.8.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
<Import Project="..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets" Condition="Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.2.0" targetFramework="net462" />
<package id="xunit" version="2.3.1" targetFramework="net462" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.msbuild" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.analyzers" version="0.8.0" targetFramework="net462" />
<package id="xunit.assert" version="2.3.1" targetFramework="net462" />
<package id="xunit.core" version="2.3.1" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.3.1" targetFramework="net462" />
<package id="xunit.runner.console" version="2.3.1" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.msbuild" version="2.3.1" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.3.1" targetFramework="net462" developmentDependency="true" />
</packages>

View File

@ -33,8 +33,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GitVersionTask" version="3.6.5" targetFramework="net462" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net462" />
</packages>

View File

@ -40,9 +40,8 @@
<HintPath>..\..\packages\Piwik.Analytics.0.3.0\lib\net40\Piwik.Analytics.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Piwik.Tracker, Version=2.16.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Piwik.Tracker.2.16.0.0\lib\net40\Piwik.Tracker.dll</HintPath>
<Private>True</Private>
<Reference Include="Piwik.Tracker, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Piwik.Tracker.3.0.0\lib\net40\Piwik.Tracker.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@ -27,32 +27,32 @@ namespace Teknik.Piwik
sub = "dev - " + sub;
}
PiwikTracker.URL = config.PiwikConfig.Url;
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId);
//PiwikTracker.URL = config.PiwikConfig.Url;
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId, config.PiwikConfig.Url);
// Get Request Info
string ipAddress = request.ClientIPFromRequest(true);
tracker.setIp(ipAddress);
tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
tracker.setUrl(request.Url.ToString());
tracker.SetIp(ipAddress);
tracker.SetTokenAuth(config.PiwikConfig.TokenAuth);
tracker.SetUrl(request.Url.ToString());
tracker.setUserAgent(request.UserAgent);
tracker.SetUserAgent(request.UserAgent);
// Get browser info
tracker.setResolution(request.Browser.ScreenPixelsWidth, request.Browser.ScreenPixelsHeight);
tracker.setBrowserHasCookies(request.Browser.Cookies);
tracker.SetResolution(request.Browser.ScreenPixelsWidth, request.Browser.ScreenPixelsHeight);
tracker.SetBrowserHasCookies(request.Browser.Cookies);
if (!string.IsNullOrEmpty(request.Headers["Accept-Language"]))
tracker.setBrowserLanguage(request.Headers["Accept-Language"]);
tracker.SetBrowserLanguage(request.Headers["Accept-Language"]);
BrowserPlugins plugins = new BrowserPlugins();
plugins.java = request.Browser.JavaApplets;
tracker.setPlugins(plugins);
plugins.Java = request.Browser.JavaApplets;
tracker.SetPlugins(plugins);
// Get Referral
if (request.UrlReferrer != null)
tracker.setUrlReferrer(request.UrlReferrer.ToString());
tracker.SetUrlReferrer(request.UrlReferrer.ToString());
// Send the tracking request
tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
tracker.DoTrackPageView(string.Format("{0}/{1}", sub, title));
}
}
catch (Exception ex)
@ -63,15 +63,15 @@ namespace Teknik.Piwik
public static void TrackDownload(HttpRequestBase request, Config config, string url)
{
TrackAction(request, config, url, PiwikTracker.ActionType.download);
TrackAction(request, config, url, ActionType.Download);
}
public static void TrackLink(HttpRequestBase request, Config config, string url)
{
TrackAction(request, config, url, PiwikTracker.ActionType.link);
TrackAction(request, config, url, ActionType.Link);
}
private static void TrackAction(HttpRequestBase request, Config config, string url, PiwikTracker.ActionType type)
private static void TrackAction(HttpRequestBase request, Config config, string url, ActionType type)
{
try
{
@ -79,21 +79,20 @@ namespace Teknik.Piwik
string doNotTrack = request.Headers["DNT"];
if (string.IsNullOrEmpty(doNotTrack) || doNotTrack != "1")
{
PiwikTracker.URL = config.PiwikConfig.Url;
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId);
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId, config.PiwikConfig.Url);
tracker.setUserAgent(request.UserAgent);
tracker.SetUserAgent(request.UserAgent);
string ipAddress = request.ClientIPFromRequest(true);
tracker.setIp(ipAddress);
tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
tracker.SetIp(ipAddress);
tracker.SetTokenAuth(config.PiwikConfig.TokenAuth);
// Get Referral
if (request.UrlReferrer != null)
tracker.setUrlReferrer(request.UrlReferrer.ToString());
tracker.SetUrlReferrer(request.UrlReferrer.ToString());
tracker.doTrackAction(url, type);
tracker.DoTrackAction(url, type);
}
}
catch (Exception ex)

View File

@ -6,5 +6,5 @@
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="Piwik.Analytics" version="0.3.0" targetFramework="net462" />
<package id="Piwik.Tracker" version="2.16.0.0" targetFramework="net462" />
<package id="Piwik.Tracker" version="3.0.0" targetFramework="net462" />
</packages>

View File

@ -51,18 +51,24 @@
<Reference Include="Mime-Detective, Version=0.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mime-Detective.0.0.5\lib\net45\Mime-Detective.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\..\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll</HintPath>
<Private>True</Private>
<Reference Include="MySql.Data, Version=6.10.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\..\packages\MySql.Data.6.10.6\lib\net452\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
@ -147,6 +153,19 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="docs\MySqlCommand.xml" />
<Content Include="docs\MySqlCommandBuilder.xml" />
<Content Include="docs\MySqlConnection.xml" />
<Content Include="docs\MySqlConnectionStringBuilder.xml" />
<Content Include="docs\MySqlDataAdapter.xml" />
<Content Include="docs\MySqlDataReader.xml" />
<Content Include="docs\MySqlException.xml" />
<Content Include="docs\MySqlHelper.xml" />
<Content Include="docs\MySqlParameter.xml" />
<Content Include="docs\MySqlParameterCollection.xml" />
<Content Include="docs\MySqlTransaction.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@ -19,6 +19,6 @@
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
<add description=".Net Framework Data Provider for MySQL" invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data></configuration>

View File

@ -0,0 +1,934 @@
<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>
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>
Using the '@' symbol for paramters is now the preferred approach although the old pattern of using
'?' is still supported. Please be aware though that using '@' can cause conflicts when user variables
are also used. To help with this situation please see the documentation on the 'allow user variables'
connection string option. The 'old syntax' connection string option has now been deprecated.
</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="vbnet">
Public Sub InsertRow(myConnectionString As String)
&quot; 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="vbnet">
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>
<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="vbnet">
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.
<code lang="vbnet">
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>
<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.
<code lang="vbnet">
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>
</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.
<code lang="vbnet">
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>
<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="vbnet">
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="vbnet">
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())
{
Console.WriteLine(myReader.GetString(0));
}
}
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="VB.NET">
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>
<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>
</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="vbnet">
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-&gt;Connection-&gt;Open();
myCommand-&gt;ExecuteScalar();
myConnection-&gt;Close();
}
</code>
</example>
</ExecuteScalar>
<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. Starting with Connector/Net 5.0, having both a stored function
and stored procedure with the same name in the same database is not supported. It is
suggested that you provide unqiue names for your stored routines.
</para>
</remarks>
<example>
The following example creates a <see cref="MySqlCommand"/> and sets some of its properties.
<code lang="vbnet">
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>
<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 30
seconds.
</value>
<remarks>
CommandTimeout is dependent on the ability of MySQL to cancel an executing query.
Because of this, CommandTimeout is only supported when connected to MySQL
version 5.0.0 or higher.
</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="vbnet">
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="vbnet">
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>
<LastInsertedId>
<summary>Provides the id of the last inserted row.</summary>
<value>
Id of the last inserted row. -1 if none exists.
</value>
<remarks>
An important point to remember is that this property can be used
in batch SQL scenarios but it's important to remember that it will
only reflect the insert id from the last insert statement in the batch.
This property can also be used when the batch includes select statements
and ExecuteReader is used. This property can be consulted during result set
processing.
</remarks>
</LastInsertedId>
<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="vbnet">
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() &amp; 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&lt;myParamArray.Length; j++)
{
myCommand.Parameters.Add(myParamArray[j]) ;
}
string myMessage = "";
for (int i = 0; i &lt; 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>
<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>
</docs>

View File

@ -0,0 +1,321 @@
<docs>
<class>
<summary>
Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
</summary>
<remarks>
<para>
The <see cref="MySqlDataAdapter"/> does not automatically generate the SQL statements required to
reconcile changes made to a <see cref="System.Data.DataSet">DataSet</see> with the associated instance of MySQL.
However, you can create a <B>MySqlCommandBuilder</B> object to automatically generate SQL statements for
single-table updates if you set the <see cref="MySqlDataAdapter.SelectCommand">SelectCommand</see> property
of the <B>MySqlDataAdapter</B>. Then, any additional SQL statements that you do not set are generated by the
<B>MySqlCommandBuilder</B>.
</para>
<para>
The <B>MySqlCommandBuilder</B> registers itself as a listener for <see cref="MySqlDataAdapter.OnRowUpdating">RowUpdating</see>
events whenever you set the <see cref="DataAdapter"/> property. You can only associate one
<B>MySqlDataAdapter</B> or <B>MySqlCommandBuilder</B> object with each other at one time.
</para>
<para>
To generate INSERT, UPDATE, or DELETE statements, the <B>MySqlCommandBuilder</B> uses the
<B>SelectCommand</B> property to retrieve a required set of metadata automatically. If you change
the <B>SelectCommand</B> after the metadata has is retrieved (for example, after the first update), you
should call the <see cref="RefreshSchema"/> method to update the metadata.
</para>
<para>
The <B>SelectCommand</B> must also return at least one primary key or unique
column. If none are present, an <I>InvalidOperation</I> exception is generated,
and the commands are not generated.
</para>
<para>
The <B>MySqlCommandBuilder</B> also uses the <see cref="MySqlCommand.Connection">Connection</see>,
<see cref="MySqlCommand.CommandTimeout">CommandTimeout</see>, and <see cref="MySqlCommand.Transaction">Transaction</see>
properties referenced by the <B>SelectCommand</B>. The user should call
<B>RefreshSchema</B> if any of these properties are modified, or if the
<B>SelectCommand</B> itself is replaced. Otherwise the <see cref="MySqlDataAdapter.InsertCommand">InsertCommand</see>,
<see cref="MySqlDataAdapter.UpdateCommand">UpdateCommand</see>, and
<see cref="MySqlDataAdapter.DeleteCommand">DeleteCommand</see> properties retain
their previous values.
</para>
<para>
If you call <i>Dispose</i>, the <B>MySqlCommandBuilder</B> is disassociated
from the <B>MySqlDataAdapter</B>, and the generated commands are no longer used.
</para>
<note>
Caution must be used when using MySqlCOmmandBuilder on MySql 4.0 systems. With MySql 4.0,
database/schema information is not provided to the connector for a query. This means that
a query that pulls columns from two identically named tables in two or more different databases
will not cause an exception to be thrown but will not work correctly. Even more dangerous
is the situation where your select statement references database X but is executed in
database Y and both databases have tables with similar layouts. This situation can cause
unwanted changes or deletes.
This note does not apply to MySQL versions 4.1 and later.
</note>
</remarks>
<example>
The following example uses the <see cref="MySqlCommand"/>, along
<see cref="MySqlDataAdapter"/> and <see cref="MySqlConnection"/>, to
select rows from a data source. The example is passed an initialized
<see cref="System.Data.DataSet"/>, a connection string, a
query string that is a SQL SELECT statement, and a string that is the
name of the database table. The example then creates a <B>MySqlCommandBuilder</B>.
<code lang="vbnet">
Public Shared Function SelectRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet
Dim myConn As New MySqlConnection(myConnection)
Dim myDataAdapter As New MySqlDataAdapter()
myDataAdapter.SelectCommand = New MySqlCommand(mySelectQuery, myConn)
Dim cb As SqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter)
myConn.Open()
Dim ds As DataSet = New DataSet
myDataAdapter.Fill(ds, myTableName)
' Code to modify data in DataSet here
' Without the MySqlCommandBuilder this line would fail.
myDataAdapter.Update(ds, myTableName)
myConn.Close()
End Function 'SelectRows
</code>
<code lang="C#">
public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName)
{
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
myConn.Open();
DataSet ds = new DataSet();
myDataAdapter.Fill(ds, myTableName);
//code to modify data in DataSet here
//Without the MySqlCommandBuilder this line would fail
myDataAdapter.Update(ds, myTableName);
myConn.Close();
return ds;
}
</code>
</example>
</class>
<Ctor>
<summary>
Initializes a new instance of the <see cref="MySqlCommandBuilder"/> class.
</summary>
</Ctor>
<Ctor2>
<summary>
Initializes a new instance of the <see cref="MySqlCommandBuilder"/> class
with the associated <see cref="MySqlDataAdapter"/> object.
</summary>
<param name="adapter">
The <see cref="MySqlDataAdapter"/> to use.
</param>
<remarks>
<para>
The <see cref="MySqlCommandBuilder"/> registers itself as a listener for
<see cref="MySqlDataAdapter.RowUpdating"/> events that are generated by the
<see cref="MySqlDataAdapter"/> specified in this property.
</para>
<para>
When you create a new instance <B>MySqlCommandBuilder</B>, any existing
<B>MySqlCommandBuilder</B> associated with this <B>MySqlDataAdapter</B>
is released.
</para>
</remarks>
</Ctor2>
<DataAdapter>
<summary>
Gets or sets a <see cref="MySqlDataAdapter"/> object for which SQL statements are automatically generated.
</summary>
<value>
A <see cref="MySqlDataAdapter"/> object.
</value>
<remarks>
<para>
The <see cref="MySqlCommandBuilder"/> registers itself as a listener for
<see cref="MySqlDataAdapter.RowUpdating"/> events that are generated by the
<see cref="MySqlDataAdapter"/> specified in this property.
</para>
<para>
When you create a new instance <B>MySqlCommandBuilder</B>, any existing
<B>MySqlCommandBuilder</B> associated with this <B>MySqlDataAdapter</B>
is released.
</para>
</remarks>
</DataAdapter>
<QuotePrefix>
<summary>
Gets or sets the beginning character or characters to use when specifying MySQL
database objects (for example, tables or columns) whose names contain
characters such as spaces or reserved tokens.
</summary>
<value>
The beginning character or characters to use. The default value is `.
</value>
<remarks>
Database objects in MySQL can contain special characters such as spaces that would
make normal SQL strings impossible to correctly parse. Use of the <b>QuotePrefix</b>
and the <see cref="QuoteSuffix"/> properties allows the <see cref="MySqlCommandBuilder"/>
to build SQL commands that handle this situation.
</remarks>
</QuotePrefix>
<QuoteSuffix>
<summary>
Gets or sets the beginning character or characters to use when specifying MySQL
database objects (for example, tables or columns) whose names contain
characters such as spaces or reserved tokens.
</summary>
<value>
The beginning character or characters to use. The default value is `.
</value>
<remarks>
Database objects in MySQL can contain special characters such as spaces that would
make normal SQL strings impossible to correctly parse. Use of the <see cref="QuotePrefix"/>
and the <b>QuoteSuffix</b> properties allows the <see cref="MySqlCommandBuilder"/>
to build SQL commands that handle this situation.
</remarks>
</QuoteSuffix>
<DeriveParameters>
<summary>
</summary>
<remarks>
</remarks>
</DeriveParameters>
<GetDeleteCommand>
<summary>
Gets the automatically generated <see cref="MySqlCommand"/> object
required to perform deletions on the database.
</summary>
<returns>
The <see cref="MySqlCommand"/> object generated to handle delete operations.
</returns>
<remarks>
<para>
An application can use the <B>GetDeleteCommand</B> method for informational
or troubleshooting purposes because it returns the <see cref="MySqlCommand"/>
object to be executed.
</para>
<para>
You can also use <B>GetDeleteCommand</B> as the basis of a modified command.
For example, you might call <B>GetDeleteCommand</B> and modify the
<see cref="MySqlCommand.CommandTimeout"/> value, and then explicitly set that on the
<see cref="MySqlDataAdapter"/>.
</para>
<para>
After the SQL statement is first generated, the application must explicitly
call <see cref="RefreshSchema"/> if it changes the statement in any way.
Otherwise, the <B>GetDeleteCommand</B> will be still be using information
from the previous statement, which might not be correct. The SQL statements
are first generated either when the application calls
<see cref="System.Data.Common.DataAdapter.Update"/> or <B>GetDeleteCommand</B>.
</para>
</remarks>
</GetDeleteCommand>
<GetInsertCommand>
<summary>
Gets the automatically generated <see cref="MySqlCommand"/> object
required to perform insertions on the database.
</summary>
<returns>
The <see cref="MySqlCommand"/> object generated to handle insert operations.
</returns>
<remarks>
<para>
An application can use the <B>GetInsertCommand</B> method for informational
or troubleshooting purposes because it returns the <see cref="MySqlCommand"/>
object to be executed.
</para>
<para>
You can also use the <B>GetInsertCommand</B> as the basis of a modified command.
For example, you might call <B>GetInsertCommand</B> and modify the
<see cref="MySqlCommand.CommandTimeout"/> value, and then explicitly set that on the
<see cref="MySqlDataAdapter"/>.
</para>
<para>
After the SQL statement is first generated, the application must explicitly
call <see cref="RefreshSchema"/> if it changes the statement in any way.
Otherwise, the <B>GetInsertCommand</B> will be still be using information
from the previous statement, which might not be correct. The SQL statements
are first generated either when the application calls
<see cref="System.Data.Common.DataAdapter.Update"/> or <B>GetInsertCommand</B>.
</para>
</remarks>
</GetInsertCommand>
<GetUpdateCommand>
<summary>
Gets the automatically generated <see cref="MySqlCommand"/> object
required to perform updates on the database.
</summary>
<returns>
The <see cref="MySqlCommand"/> object generated to handle update operations.
</returns>
<remarks>
<para>
An application can use the <B>GetUpdateCommand</B> method for informational
or troubleshooting purposes because it returns the <see cref="MySqlCommand"/>
object to be executed.
</para>
<para>
You can also use <B>GetUpdateCommand</B> as the basis of a modified command.
For example, you might call <B>GetUpdateCommand</B> and modify the
<see cref="MySqlCommand.CommandTimeout"/> value, and then explicitly set that on the
<see cref="MySqlDataAdapter"/>.
</para>
<para>
After the SQL statement is first generated, the application must explicitly
call <see cref="RefreshSchema"/> if it changes the statement in any way.
Otherwise, the <B>GetUpdateCommand</B> will be still be using information
from the previous statement, which might not be correct. The SQL statements
are first generated either when the application calls
<see cref="System.Data.Common.DataAdapter.Update"/> or <B>GetUpdateCommand</B>.
</para>
</remarks>
</GetUpdateCommand>
<RefreshSchema>
<summary>
Refreshes the database schema information used to generate INSERT, UPDATE, or
DELETE statements.
</summary>
<remarks>
<para>
An application should call <B>RefreshSchema</B> whenever the SELECT statement
associated with the <see cref="MySqlCommandBuilder"/> changes.
</para>
<para>
An application should call <B>RefreshSchema</B> whenever the
<see cref="MySqlDataAdapter.SelectCommand"/> value of the <see cref="MySqlDataAdapter"/> changes.
</para>
</remarks>
</RefreshSchema>
</docs>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
<docs>
<Server>
<summary>
Gets or sets the name or address of the MySQL instance to connect to.
</summary>
<remarks>
If this property is not set, then the provider will attempt to
connect to <b>localhost</b> even though this property will return
<b>String.Empty</b>.
</remarks>
<example>
</example>
</Server>
<Database>
<summary>
Gets or sets the name of the database that should be selected
when the connection is first opened.
</summary>
<remarks>
There is no default for this property and, if not set, the
connection will not have a current database until one is set
using the <see cref="ChangeDatabase"/> method.
</remarks>
<example>
</example>
</Database>
<ConnectionProtocol>
<summary>
Gets or sets the connection protocol that is being used for this
connection.
</summary>
<remarks>
</remarks>
<example>
</example>
</ConnectionProtocol>
<PipeName>
<summary>
Gets or sets the name of the named pipe object that the provider
should use.
</summary>
<remarks>
This property has no effect unless the <see cref="ConnectionProtocol"/>
property has been set to <b>NamedPipe</b>.
</remarks>
<example>
</example>
</PipeName>
</docs>

View File

@ -0,0 +1,801 @@
<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(DataSet)"/>, which changes the data in the
<B>DataSet</B> to match the data in the data source, and <see cref="System.Data.Common.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(DataTable, 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 allows only
Int16, Int32, and Int64 to have the AutoIncrement property set.
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="vbnet">
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="vbnet">
Public Sub CreateSqlDataAdapter()
Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" &amp; _
"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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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);
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;
}
</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="vbnet">
Public Sub CreateSqlDataAdapter()
Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" &amp; _
"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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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.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;
}
</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(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="vbnet">
Public Sub CreateSqlDataAdapter()
Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" &amp; _
"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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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.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;
}
</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="vbnet">
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) " &amp; _
"VALUES (@id, @name)", conn)
da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " &amp; _
"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.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.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;
}
</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.DbDataAdapter.Update(System.Data.DataSet)"/> 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.DbDataAdapter.Update(System.Data.DataSet)"/>, 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="vbnet">
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 DeleteCommand.
cmd = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn)
parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id")
parm.SourceVersion = DataRowVersion.Original
da.DeleteCommand = 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 DeleteCommand.
cmd = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn);
parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id");
parm.SourceVersion = DataRowVersion.Original;
da.DeleteCommand = cmd;
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.DbDataAdapter.Update(System.Data.DataSet)"/> 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.DbDataAdapter.Update(System.Data.DataSet)"/>, 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="vbnet">
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>
</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.DbDataAdapter.Update(System.Data.DataSet)"/> to update records in the
database with data from the <see cref="DataSet"/>.
</value>
<remarks>
<para>
During <see cref="System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)"/>, 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="vbnet">
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="vbnet">
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>

View File

@ -0,0 +1,452 @@
<docs>
<ClassSummary>
<summary>
Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
</summary>
<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="vbnet">
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) &amp; ", " &amp; 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>
<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>
<overloads/>
<summary>
Gets the value of the specified column as a <see cref="TimeSpan"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Time</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
<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(int)"/>.
</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="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetDateTime>
<GetDateTimeS>
<summary>
Gets the value of the specified column as a <see cref="DateTime"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
<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(int)"/>.
</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="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetDateTimeS>
<GetMySqlDateTime>
<summary>
Gets the value of the specified column as a <see cref="MySql.Data.Types.MySqlDateTime"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>DateTime</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>String</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetString>
<GetStringS>
<summary>
Gets the value of the specified column as a <see cref="String"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>String</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetStringS>
<GetDecimal>
<summary>
Gets the value of the specified column as a <see cref="Decimal"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Decimal</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal</param>
<returns>The value of the specified column.</returns>
</GetDecimal>
<GetDecimalS>
<summary>
Gets the value of the specified column as a <see cref="Decimal"/> object.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Decimal</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetDecimalS>
<GetDouble>
<summary>Gets the value of the specified column as a double-precision floating point number.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Double</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetDouble>
<GetDoubleS>
<summary>Gets the value of the specified column as a double-precision floating point number.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Double</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetDoubleS>
<GetFloat>
<summary>
Gets the value of the specified column as a single-precision floating point number.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Float</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetFloat>
<GetFloatS>
<summary>
Gets the value of the specified column as a single-precision floating point number.
</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>Float</b> object.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetFloatS>
<GetGiud>
<summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetGiud>
<GetGiudS>
<summary>Gets the value of the specified column as a globally-unique identifier (GUID).</summary>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetGiudS>
<GetInt16>
<summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>16 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetInt16>
<GetInt16S>
<summary>Gets the value of the specified column as a 16-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; threfore, the data retrieved must already be a <b>16 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name</param>
<returns>The value of the specified column.</returns>
</GetInt16S>
<GetInt32>
<summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>32 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetInt32>
<GetInt32S>
<summary>Gets the value of the specified column as a 32-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>32 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetInt32S>
<GetInt64>
<summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>64 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="i">The zero-based column ordinal.</param>
<returns>The value of the specified column.</returns>
</GetInt64>
<GetInt64S>
<summary>Gets the value of the specified column as a 64-bit signed integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>64 bit integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The column name.</param>
<returns>The value of the specified column.</returns>
</GetInt64S>
<GetUInt16>
<summary>Gets the value of the specified column as a 16-bit unsigned integer.</summary>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>16 bit unsigned integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>32 bit unsigned integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</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>
<remarks>
<para>
No conversions are performed; therefore, the data retrieved must already be a <b>64 bit unsigned integer</b> value.
</para>
<para>
Call IsDBNull to check for null values before calling this method.
</para>
</remarks>
<param name="column">The zero-based column ordinal or column name.</param>
<returns>The value of the specified column.</returns>
</GetUInt64>
</docs>

View File

@ -0,0 +1,53 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
<para>
This class is created whenever the MySql Data Provider encounters an error generated from the server.
</para>
<para>
Any open connections are not automatically closed when an exception is thrown. If
the client application determines that the exception is fatal, it should close any open
<see cref="MySqlDataReader"/> objects or <see cref="MySqlConnection"/> objects.
</para>
</remarks>
<example>
The following example generates a <B>MySqlException</B> due to a missing server,
and then displays the exception.
<code lang="vbnet">
Public Sub ShowException()
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;")
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch e As MySqlException
MessageBox.Show( e.Message )
End Try
End Sub
</code>
<code lang="C#">
public void ShowException()
{
string mySelectQuery = "SELECT column1 FROM table1";
MySqlConnection myConnection =
new MySqlConnection("Data Source=localhost;Database=Sample;");
MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (MySqlException e)
{
MessageBox.Show( e.Message );
}
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,53 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
<para>
This class is created whenever the MySql Data Provider encounters an error generated from the server.
</para>
<para>
Any open connections are not automatically closed when an exception is thrown. If
the client application determines that the exception is fatal, it should close any open
<see cref="MySqlDataReader"/> objects or <see cref="MySqlConnection"/> objects.
</para>
</remarks>
<example>
The following example generates a <B>MySqlException</B> due to a missing server,
and then displays the exception.
<code lang="vbnet">
Public Sub ShowException()
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;")
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch e As MySqlException
MessageBox.Show( e.Message )
End Try
End Sub
</code>
<code lang="C#">
public void ShowException()
{
string mySelectQuery = "SELECT column1 FROM table1";
MySqlConnection myConnection =
new MySqlConnection("Data Source=localhost;Database=Sample;");
MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (MySqlException e)
{
MessageBox.Show( e.Message );
}
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,45 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
Parameter names are not case sensitive.
</remarks>
<example>
The following example creates multiple instances of <B>MySqlParameter</B> through the
<see cref="MySqlParameterCollection"/> collection within the <see cref="MySqlDataAdapter"/>.
These parameters are used to select data from the data source and place the data
in the <see cref="DataSet"/>. This example assumes that a <B>DataSet</B> and a
<B>MySqlDataAdapter</B> have already been created with the appropriate schema, commands,
and connection.
<code lang="vbnet">
Public Sub AddSqlParameters()
' ...
' create myDataSet and myDataAdapter
' ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239
myDataAdapter.Fill(myDataSet)
End Sub 'AddSqlParameters
</code>
<code lang="C#">
public void AddSqlParameters()
{
// ...
// create myDataSet and myDataAdapter
// ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;
myDataAdapter.Fill(myDataSet);
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,45 @@
<MyDocs>
<MyMembers name="Class">
<remarks>
The number of the parameters in the collection must be equal to the number of
parameter placeholders within the command text, or an exception will be generated.
</remarks>
<example>
The following example creates multiple instances of <see cref="MySqlParameter"/>
through the <B>MySqlParameterCollection</B> collection within the <see cref="MySqlDataAdapter"/>.
These parameters are used to select data within the data source and place the data in
the <see cref="System.Data.DataSet"/>. This code assumes that a <B>DataSet</B> and a <B>MySqlDataAdapter</B>
have already been created with the appropriate schema, commands, and connection.
<code lang="vbnet">
Public Sub AddParameters()
' ...
' create myDataSet and myDataAdapter
' ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239
myDataAdapter.Fill(myDataSet)
End Sub 'AddSqlParameters
</code>
<code lang="C#">
public void AddSqlParameters()
{
// ...
// create myDataSet and myDataAdapter
// ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;
myDataAdapter.Fill(myDataSet);
}
</code>
</example>
</MyMembers>
</MyDocs>

View File

@ -0,0 +1,329 @@
<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="vbnet">
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 " &amp; ex.GetType().ToString() &amp; _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _
"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 a <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="vbnet">
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 " &amp; ex.GetType().ToString() &amp; _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _
"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>
</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 a <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="vbnet">
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 " &amp; ex.GetType().ToString() &amp; _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Console.WriteLine("An exception of type " &amp; e.GetType().ToString() &amp; _
"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>

View File

@ -10,8 +10,8 @@
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="Mime-Detective" version="0.0.5" targetFramework="net462" />
<package id="MySql.Data" version="6.9.9" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net462" />
<package id="MySql.Data" version="6.10.6" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net462" />
<package id="System.Xml.XmlSerializer" version="4.3.0" targetFramework="net462" />
<package id="WebGrease" version="1.6.0" targetFramework="net462" />
</packages>

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props" Condition="Exists('..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props')" />
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props" Condition="Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props')" />
<Import Project="..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props" Condition="Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" />
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -46,17 +48,14 @@
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -73,14 +72,23 @@
<Name>Utilities</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\xunit.analyzers.0.8.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.msbuild.2.2.0\build\net452\xunit.runner.msbuild.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
<Import Project="..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets" Condition="Exists('..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.2.0" targetFramework="net462" />
<package id="xunit" version="2.3.1" targetFramework="net462" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.msbuild" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.analyzers" version="0.8.0" targetFramework="net462" />
<package id="xunit.assert" version="2.3.1" targetFramework="net462" />
<package id="xunit.core" version="2.3.1" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.3.1" targetFramework="net462" />
<package id="xunit.runner.console" version="2.3.1" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.msbuild" version="2.3.1" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.3.1" targetFramework="net462" developmentDependency="true" />
</packages>