<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>luauf.com &#187; Mono</title>
	<atom:link href="http://luauf.com/category/programacion/mono-programacion/feed/" rel="self" type="application/rss+xml" />
	<link>http://luauf.com</link>
	<description>Sistemas Operativos, Bases de Datos, Programación y Redes</description>
	<lastBuildDate>Mon, 14 May 2012 01:15:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Mono con MySQL</title>
		<link>http://luauf.com/2008/06/08/mono-con-mysql/</link>
		<comments>http://luauf.com/2008/06/08/mono-con-mysql/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 18:35:21 +0000</pubDate>
		<dc:creator>Luciano</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://luauf.com/?p=385</guid>
		<description><![CDATA[Hace un tiempo, di mis primeros pasos en Mono, con el desarrollo de unos programas muy básicos en Mono, que no iban mucho más allá del Hola Mundo. Con dar unos pasos más...]]></description>
			<content:encoded><![CDATA[<p>Hace un tiempo, di mis primeros pasos en Mono, con el desarrollo de unos <a href="http://luauf.com/2008/05/18/programas-basicos-en-csharp-con-mono/">programas muy básicos en Mono</a>, que no iban mucho más allá del Hola Mundo.</p>
<p>Con dar unos pasos más en mi intrusión con Mono, en esta ocasión desarrollaré una aplicación básica, capaz de hacer altas y bajas en una base de datos MySQL.</p>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/06/mono.jpg"><img class="aligncenter size-medium wp-image-386" title="mono" src="http://luauf.com/wp-content/uploads/2008/06/mono-300x210.jpg" alt="" width="300" height="210" /></a></p>
<p><span id="more-385"></span></p>
<ul>
<li>Descargar la librería dinámica para conectarnos a MySQL. Descargar <a href="http://www.antoniomtz.org/files/mysql.tar.gz" target="_blank">MySql.dll</a>.</li>
</ul>
<ul>
<li>Descomprimir e instalar, mejor dicho, agregar el assemblie a la caché global de ensamblados:</li>
</ul>
<p><code>
<div class="syntax_hilite">
<div id="code-8">
<div class="code">$ tar -xvzf mysql.<span style="">tar</span>.<span style="">gz</span> <br />
README<br />
MySql.<span style="">Data</span>.<span style="">dll</span><br />
$ cat README <br />
Descomprimir la .<span style="">dll</span> en alguna carpeta y correr el siguiente comando:<br />
$ gacutil -i MySql.<span style="">Data</span>.<span style="">dll</span><br />
Y linkear desde monodevelop deacuerdo al tutorial en http:<span style="color:#FF9933; font-style:italic;">//antoniomtz.org</span></p>
<p>$ sudo gacutil -i MySql.<span style="">Data</span>.<span style="">dll</span> <br />
MySql.<span style="">Data</span> installed into the gac <span style="color:#006600; font-weight:bold;">&#40;</span>/usr/lib/mono/gac<span style="color:#006600; font-weight:bold;">&#41;</span><br />
$</div>
</div>
</div>
<p>
</code></p>
<ul>
<li>Abrir el IDE <a href="http://luauf.com/2008/04/28/monodevelop-10-en-ubuntu/" target="_self">MonoDevelop</a></li>
</ul>
<ul>
<li>Crear un nuevo proyecto GTK# y agregar en las referencias del mismo (clic derecho sobre Referencias, Editar referencias):
<ul>
<li>El paquete System.Data</li>
<li>El ensamblado MySqlData.dll</li>
</ul>
</li>
</ul>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/06/referencias.png"><img class="aligncenter size-medium wp-image-387" title="referencias" src="http://luauf.com/wp-content/uploads/2008/06/referencias-300x182.png" alt="" width="300" height="182" /></a></p>
<ul>
<li>En el código, importar ambos paquetes:</li>
</ul>
<p><code></p>
<div class="syntax_hilite">
<div id="csharp-9">
<div class="csharp"><span style="color: #008080; font-style: italic;">// Main.cs created with MonoDevelop</span><br />
<span style="color: #008080; font-style: italic;">// User: luciano</span><br />
<span style="color: #008080; font-style: italic;">//</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;<br />
<span style="color: #0600FF;">using</span> Gtk;<br />
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Data</span>;<br />
<span style="color: #0600FF;">using</span> MySql.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">MySqlClient</span>;</div>
</div>
</div>
<p>
</code></p>
<ul>
<li>Crear una pequeña tabla en una base de datos MySQL y desarrollar la GUI para una pequeña aplicación desde la cual se realicen altas y bajas a la tabla:</li>
</ul>
<p><code></p>
<div class="syntax_hilite">
<div id="mysql-10">
<div class="mysql"><span style="color: #993333; font-weight: bold;">CREATE TABLE</span> `usuarios` <span style="color: #66cc66;">&#40;</span><br />
&nbsp; `id` <span style="color: #aa9933; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #aa3399; font-weight: bold;">NOT NULL</span>,<br />
&nbsp; `nombre` <span style="color: #aa9933; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span> <span style="color: #aa3399; font-weight: bold;">NOT NULL</span>,<br />
&nbsp; `apellidos` <span style="color: #aa9933; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span> <span style="color: #aa3399; font-weight: bold;">NOT NULL</span>,<br />
&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY KEY</span>&nbsp; <span style="color: #66cc66;">&#40;</span>`id`<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE=MyISAM <span style="color: #aa3399; font-weight: bold;">DEFAULT</span> <span style="color: #aa3399; font-weight: bold;">CHARSET</span>=latin1;</div>
</div>
</div>
<p>
</code></p>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/06/gui.png"><img class="aligncenter size-medium wp-image-388" title="gui" src="http://luauf.com/wp-content/uploads/2008/06/gui-300x216.png" alt="" width="300" height="216" /></a></p>
<p style="text-align: left;">
<ul>
<li>Antes de ver el código completo, veamos los aspectos principales:
<ul>
<li>Conexión con la base de datos</li>
<p><code></p>
<div class="syntax_hilite">
<div id="csharp-11">
<div class="csharp">IDbConnection conn;<br />
conn = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MySqlConnection<span style="color: #000000;">&#40;</span><span style="color: #808080;">"Server=localhost;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080;">"Database=test;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080;">"User ID=usuario;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080;">"Password=contrasena;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080;">"Pooling=false"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#41;</span>;<br />
conn.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
...<br />
<span style="color: #0000FF;">conn</span>.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</div>
</div>
<p>
</code></p>
<li>Lectura de base de datos</li>
<p><code></p>
<div class="syntax_hilite">
<div id="csharp-12">
<div class="csharp">IDbCommand comando = conn.<span style="color: #0000FF;">CreateCommand</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p><span style="color: #FF0000;">string</span> strSQL = <span style="color: #808080;">"SELECT id, nombre, apellidos FROM usuarios;"</span>;<br />
comando.<span style="color: #0000FF;">CommandText</span> = strSQL;<br />
IDataReader dr = comando.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>dr.<span style="color: #0000FF;">Read</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>&nbsp; &nbsp;<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp;&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">//dr[&quot;id&quot;]</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//dr[&quot;nombre&quot;].ToString()</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//dr[&quot;apellidos&quot;].ToString())</span><br />
<span style="color: #000000;">&#125;</span><br />
dr.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</div>
</div>
<p>
</code></p>
<li>Altas y bajas</li>
<p><code></p>
<div class="syntax_hilite">
<div id="csharp-13">
<div class="csharp">IDbCommand comando = conn.<span style="color: #0000FF;">CreateCommand</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p><span style="color: #FF0000;">string</span> strSQL = <span style="color: #808080;">"DELETE FROM ..."</span><br />
<span style="color: #FF0000;">string</span> strSQL = <span style="color: #808080;">"INSERT INTO ..."</span><br />
comando.<span style="color: #0000FF;">CommandText</span> = strSQL;<br />
comando.<span style="color: #0000FF;">ExecuteNonQuery</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</div>
</div>
<p>
</code>
</ul>
</li>
</ul>
<ul>
<li>Para finalizar, el código completo de la aplicación:</li>
</ul>
<p><code></p>
<div class="syntax_hilite">
<div id="csharp-14">
<div class="csharp"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;<br />
<span style="color: #0600FF;">using</span> Gtk;<br />
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Data</span>;<br />
<span style="color: #0600FF;">using</span> MySql.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">MySqlClient</span>;</p>
<p><span style="color: #0600FF;">public</span> partial <span style="color: #FF0000;">class</span> MainWindow: Gtk.<span style="color: #0000FF;">Window</span><br />
<span style="color: #000000;">&#123;</span>&nbsp; &nbsp;<br />
&nbsp; &nbsp; IDbConnection conn;</p>
<p>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF;">public</span> MainWindow <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>: <span style="color: #0600FF;">base</span> <span style="color: #000000;">&#40;</span>Gtk.<span style="color: #0000FF;">WindowType</span>.<span style="color: #0000FF;">Toplevel</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Build <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; conn = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MySqlConnection<span style="color: #000000;">&#40;</span><span style="color: #808080;">"Server=localhost;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">"Database=test;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">"User ID=usuario;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">"Password=contrasena;"</span> +<br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">"Pooling=false"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; treeview.<span style="color: #0000FF;">AppendColumn</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"Id"</span>, <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Gtk.<span style="color: #0000FF;">CellRendererText</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">"text"</span>, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; treeview.<span style="color: #0000FF;">AppendColumn</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"Nombre"</span>, <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Gtk.<span style="color: #0000FF;">CellRendererText</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">"text"</span>, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; treeview.<span style="color: #0000FF;">AppendColumn</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"Apellido"</span>, <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Gtk.<span style="color: #0000FF;">CellRendererText</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">"text"</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; treeview_load<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></p>
<p>
&nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> treeview_load<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; conn.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Gtk.<span style="color: #0000FF;">ListStore</span> liststoreUsuarios = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Gtk.<span style="color: #0000FF;">ListStore</span> <span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#41;</span>, <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#41;</span>, <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; treeview.<span style="color: #0000FF;">Model</span> = liststoreUsuarios;<br />
&nbsp; &nbsp; &nbsp; &nbsp; IDbCommand comando = conn.<span style="color: #0000FF;">CreateCommand</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> strSQL = <span style="color: #808080;">"SELECT id, nombre, apellidos FROM usuarios;"</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; comando.<span style="color: #0000FF;">CommandText</span> = strSQL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; IDataReader dr = comando.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>dr.<span style="color: #0000FF;">Read</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; liststoreUsuarios.<span style="color: #0000FF;">AppendValues</span><span style="color: #000000;">&#40;</span>dr<span style="color: #000000;">&#91;</span><span style="color: #808080;">"id"</span><span style="color: #000000;">&#93;</span>, dr<span style="color: #000000;">&#91;</span><span style="color: #808080;">"nombre"</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, dr<span style="color: #000000;">&#91;</span><span style="color: #808080;">"apellidos"</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dr.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; conn.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> OnDeleteEvent <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, DeleteEventArgs a<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Application.<span style="color: #0000FF;">Quit</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; a.<span style="color: #0000FF;">RetVal</span> = <span style="color: #0600FF;">true</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></p>
<p>&nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> buttonAgregar_clic <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventArgs</span> e<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; IDbCommand comando = conn.<span style="color: #0000FF;">CreateCommand</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; conn.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> strSQL = <span style="color: #808080;">"INSERT INTO usuarios VALUES ("</span> + textId.<span style="color: #0000FF;">Text</span> + <span style="color: #808080;">",'"</span> + textNombre.<span style="color: #0000FF;">Text</span> + <span style="color: #808080;">"','"</span> + textApellidos.<span style="color: #0000FF;">Text</span> + <span style="color: #808080;">"')"</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; comando.<span style="color: #0000FF;">CommandText</span> = strSQL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; comando.<span style="color: #0000FF;">ExecuteNonQuery</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; conn.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; treeview_load<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></p>
<p>&nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> OnTreeviewCursorChanged <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventArgs</span> e<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Gtk.<span style="color: #0000FF;">TreeModel</span>&nbsp; modelo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Gtk.<span style="color: #0000FF;">TreeIter</span> iterSelected;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span> treeview.<span style="color: #0000FF;">Selection</span>.<span style="color: #0000FF;">GetSelected</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">out</span> modelo, <span style="color: #0600FF;">out</span> iterSelected<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textIdEliminar.<span style="color: #0000FF;">Text</span> = <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#41;</span> modelo.<span style="color: #0000FF;">GetValue</span><span style="color: #000000;">&#40;</span>iterSelected,<span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></p>
<p>&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></p>
<p>&nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> OnButtonEliminarClicked <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventArgs</span> e<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; IDbCommand comando = conn.<span style="color: #0000FF;">CreateCommand</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; conn.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> strSQL = <span style="color: #808080;">"DELETE FROM usuarios WHERE id = "</span> + textIdEliminar.<span style="color: #0000FF;">Text</span> ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; comando.<span style="color: #0000FF;">CommandText</span> = strSQL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; comando.<span style="color: #0000FF;">ExecuteNonQuery</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; conn.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; treeview_load<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></p>
<p><span style="color: #000000;">&#125;</span></div>
</div>
</div>
<p>
</code></p>
<p style="text-align: left;">
<p style="text-align: left;">Basado en la publicación original de<a href="http://ver18.wordpress.com/2008/05/31/programacion-mono-mysql-altas-y-bajas/" target="_blank"> Noticias, Eventos y mucho mas de SOFTWARE LIBRE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://luauf.com/2008/06/08/mono-con-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

