<?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>MySQL &#8211; Tjitjing Blog</title>
	<atom:link href="http://localhost/index.php/category/mysql/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.tjitjing.com/</link>
	<description>This is my blog on technology related stuff and on occation other things too...</description>
	<lastBuildDate>Wed, 13 Jul 2016 16:46:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.16</generator>
	<item>
		<title>Set separator delimiter in CSV file to open correctly in Excel</title>
		<link>https://blog.tjitjing.com/index.php/2016/07/set-separator-delimiter-in-csv-file-to-open-correctly-in-excel.html</link>
					<comments>https://blog.tjitjing.com/index.php/2016/07/set-separator-delimiter-in-csv-file-to-open-correctly-in-excel.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Wed, 13 Jul 2016 16:46:17 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Office 365]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Export]]></category>
		<category><![CDATA[Import]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/?p=752</guid>

					<description><![CDATA[Problem I made a PHP script to export a SQL query (from MySql) to a CSV file for opening in Excel. I cannot control how different users have their Excel setup, ie what separator delimiter they have set (this differs with language settings or user may have changed setting) So the field separator delimiter gave me some problems,&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2016/07/set-separator-delimiter-in-csv-file-to-open-correctly-in-excel.html">Continue reading <span class="screen-reader-text">Set separator delimiter in CSV file to open correctly in Excel</span></a>]]></description>
										<content:encoded><![CDATA[<h2>Problem</h2>
<p>I made a PHP script to export a SQL query (from MySql) to a CSV file for opening in Excel. I cannot control how different users have their Excel setup, ie what separator delimiter they have set (this differs with language settings or user may have changed setting)</p>
<p>So the field separator delimiter gave me some problems, ie Excel would not automatically open file columns correctly but put each row in a single cell, unless you use Import data to make it work.</p>
<p>Some forums suggested setting the separator delimiter in the csv file (delimiter is third argument for <a href="http://php.net/manual/en/function.fputcsv.php" target="_blank" rel="noopener noreferrer">fputcsv</a>) to tab (\t) but that did not help.</p>
<h2>Solution (use csv header sep=)</h2>
<p>Then I stumbled upon the possibility to add a parameter as a header to the actual csv file, simply add sep=&lt;delimiter&gt; to the beginning of your csv file and Excel will parse it. So for separator delimiter use comma (,), pipe (|), tab (\t) or whatever you set in your php code.</p>
<p>However I found a few caveats:</p>
<ul>
<li>&#8220;sep=\t&#8221; needs to be in quotes (otherwise it will use header but also for some reason also show it as data in the spreadsheet and put it in its own cell and move all other cells on that row one position to the right)</li>
<li>You need to add newline \n after the sep= header (otherwise it will use header but also show it as data concatenated with first cells data)</li>
<li>Use fwrite as fputcsv will not work</li>
</ul>
<p>Example to use tab as separator:</p>
<p>[code]fwrite($fp, &quot;\&quot;sep=\t\&quot;\n&quot;);[/code]</p>
<p>&nbsp;</p>
<p>I could not find much info on the subject of csv headers but <a href="http://superuser.com/questions/773644/what-is-the-sep-metadata-you-can-add-to-csvs" target="_blank" rel="noopener noreferrer">this is the full thread</a> that lead me on the to it (thanks Burhan Ali)</p>
<p>Tested with Excel 2016 on Windows 10 and Excel for Mac (15.25) on OSX El Capitan (10.11.15).</p>
<p>I have not tested on other spreadsheets software like OpenOffice, LibreOffice etc, so please share in the comments if you have any success with this.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2016/07/set-separator-delimiter-in-csv-file-to-open-correctly-in-excel.html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>MySQL and Visual Studio 2010 Membership, Roles and User Profile Provider</title>
		<link>https://blog.tjitjing.com/index.php/2010/06/mysql-and-visual-studio-2010-membership-roles-and-user-profile-provider.html</link>
					<comments>https://blog.tjitjing.com/index.php/2010/06/mysql-and-visual-studio-2010-membership-roles-and-user-profile-provider.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Thu, 17 Jun 2010 00:20:46 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Membership Provider]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VS 2010]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/?p=253</guid>

					<description><![CDATA[In Visual Studio 2010 (VS2010) when you create a new Web Application Project using the default Web Template &#8220;ASP.NET Web Application&#8221; it creates an Account folder with the files Login.aspx, Register.aspx and ChangePassword.aspx. These are files/pages for ASP.NET Membership which is ASP.NET&#8217;s built-in user handling. I have never used Membership before but have been curious&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2010/06/mysql-and-visual-studio-2010-membership-roles-and-user-profile-provider.html">Continue reading <span class="screen-reader-text">MySQL and Visual Studio 2010 Membership, Roles and User Profile Provider</span></a>]]></description>
										<content:encoded><![CDATA[<p>In Visual Studio 2010 (VS2010)  when you create a new Web Application Project using the default Web Template &#8220;ASP.NET Web Application&#8221; it creates an Account folder with the files Login.aspx, Register.aspx and ChangePassword.aspx.<br />
These are files/pages for <a target="_blank" href="http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx" rel="noopener noreferrer">ASP.NET Membership</a> which is ASP.NET&#8217;s built-in user handling. I have never used Membership before but have been curious to, so I saw this as my cue to do so. However since I&#8217;m running MySQL as my database server I knew I had some extra installing and configuring to do. </p>
<p>Now several hours later I have finally figured out what I needed to do&#8230;</p>
<p><strong>1) Install the <a target="_blank" href="http://dev.mysql.com/downloads/connector/net/" rel="noopener noreferrer">latest version of MySQL Connector/NET</a>. Visual Studio support is from version 6.3 which is currently only available in beta, current version when writing this is 6.3.2 beta.</p>
<p>2) Use the <a target="_blank" href="http://dev.mysql.com/doc/refman/5.5/en/connector-net-website-config.html" rel="noopener noreferrer">MySQL Website Configuration Tool, follow instructions found by clicking this link</a>. This tool will modify necessary configuration files (have not checked which, maybe only web.config) to use MySQL Membership, Roles, User Profile and/or Session State.</p>
<p>Important: (this took me quite some time to figure out) the MySQL Website Configuration Tool icon only shows up in the Solution Explorer if you create a Web Site Project in VS 2010. It does not show if you create a Web Application Project. I have reported this as a <a target="_blank" href="http://bugs.mysql.com/bug.php?id=54571" rel="noopener noreferrer">bug to MySQL</a>.</p>
<p>The only workaround I found to use a Web Application instead of using a Web Site was to create a temp Web Site project, run the MySQL Web Configuration Tool and then use copy and paste to move changes from web.confg to my Web Application Project. I have provided these changes at the end of this post.</p>
<p>3) Done!<br />
</strong></p>
<p>I am running Windows 7 64-bit, Visual Studio 2010 and MySQL Connector/NET 6.3.2 beta, but <a target="_blank" href="http://forums.mysql.com/read.php?38,277438,277438" rel="noopener noreferrer">according to this thread</a> other people with other versions of VS seems to be having the same problem.</p>
<p>These are the changes that are made to web.config:<br />
 [code lang=&#8221;xml&#8221;]<br />
  &lt;connectionStrings&gt;<br />
    &lt;remove name=&quot;LocalMySqlServer&quot; /&gt;<br />
    &lt;add name=&quot;LocalMySqlServer&quot; connectionString=&quot;server=localhost;User Id=root;database=users;password=xxx&quot; providerName=&quot;MySql.Data.MySqlClient&quot; /&gt;<br />
  &lt;/connectionStrings&gt;<br />
[/code] </p>
<p>[code lang=&#8221;xml&#8221;]<br />
&lt;system.web&gt;<br />
    &lt;authentication mode=&quot;Forms&quot;&gt;<br />
      &lt;forms loginUrl=&quot;~/Account/Login.aspx&quot; timeout=&quot;2880&quot; /&gt;<br />
    &lt;/authentication&gt;<br />
    &lt;membership defaultProvider=&quot;MySQLMembershipProvider&quot;&gt;<br />
      &lt;providers&gt;<br />
      &lt;clear /&gt;<br />
      &lt;remove name=&quot;MySQLMembershipProvider&quot; /&gt;<br />
        &lt;add name=&quot;MySQLMembershipProvider&quot; type=&quot;MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d&quot; applicationName=&quot;/&quot; description=&quot;MySQL default application&quot; connectionStringName=&quot;LocalMySqlServer&quot; writeExceptionsToEventLog=&quot;True&quot; autogenerateschema=&quot;True&quot; enablePasswordRetrieval=&quot;True&quot; enablePasswordReset=&quot;True&quot; requiresQuestionAndAnswer=&quot;False&quot; requiresUniqueEmail=&quot;False&quot; passwordFormat=&quot;Clear&quot; maxInvalidPasswordAttempts=&quot;5&quot; minRequiredPasswordLength=&quot;6&quot; minRequiredNonalphanumericCharacters=&quot;1&quot; passwordAttemptWindow=&quot;10&quot; passwordStrengthRegularExpression=&quot;&quot; /&gt;<br />
      &lt;/providers&gt;<br />
    &lt;/membership&gt;<br />
    &lt;profile defaultProvider=&quot;MySQLProfileProvider&quot;&gt;<br />
      &lt;providers&gt;<br />
        &lt;clear /&gt;<br />
        &lt;remove name=&quot;MySQLProfileProvider&quot; /&gt;<br />
        &lt;add name=&quot;MySQLProfileProvider&quot; type=&quot;MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.3.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d&quot; applicationName=&quot;/&quot; description=&quot;&quot; connectionStringName=&quot;LocalMySqlServer&quot; writeExceptionsToEventLog=&quot;False&quot; autogenerateschema=&quot;True&quot; /&gt;<br />
      &lt;/providers&gt;<br />
    &lt;/profile&gt;<br />
    &lt;roleManager enabled=&quot;false&quot; defaultProvider=&quot;MySQLRoleProvider&quot;&gt;<br />
      &lt;providers&gt;<br />
        &lt;clear /&gt;<br />
        &lt;remove name=&quot;MySQLRoleProvider&quot; /&gt;<br />
        &lt;add name=&quot;MySQLRoleProvider&quot; type=&quot;MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.3.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d&quot; applicationName=&quot;/&quot; description=&quot;&quot; connectionStringName=&quot;LocalMySqlServer&quot; writeExceptionsToEventLog=&quot;True&quot; autogenerateschema=&quot;True&quot; /&gt;<br />
      &lt;/providers&gt;<br />
    &lt;/roleManager&gt;<br />
  &lt;/system.web&gt;</p>
<p>[/code]<br />
</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2010/06/mysql-and-visual-studio-2010-membership-roles-and-user-profile-provider.html/feed</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>MySQL Workbench Query Browser is super slow</title>
		<link>https://blog.tjitjing.com/index.php/2010/05/mysql-workbench-query-browser-sql-development-is-super-slow.html</link>
					<comments>https://blog.tjitjing.com/index.php/2010/05/mysql-workbench-query-browser-sql-development-is-super-slow.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sun, 09 May 2010 09:22:31 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL GUI Tools]]></category>
		<category><![CDATA[MySQL Query Browser]]></category>
		<category><![CDATA[MySQL Workbench]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/?p=235</guid>

					<description><![CDATA[MySQL GUI Tools which included the MySQL Query Browser and MySQL Administrator has now been replaced by the MySQL Workbench tool. The Workbench edition which includes Query Browser (now called SQL Development) and Administrator (now called Server Administration) is only available in beta but it the old MySQL GUI Tools have already been pulled from&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2010/05/mysql-workbench-query-browser-sql-development-is-super-slow.html">Continue reading <span class="screen-reader-text">MySQL Workbench Query Browser is super slow</span></a>]]></description>
										<content:encoded><![CDATA[<p><strong>MySQL GUI Tools which included the MySQL Query Browser and MySQL Administrator has now been replaced by the <a href="http://wb.mysql.com/" target="_blank" rel="noopener noreferrer">MySQL Workbench</a> tool.</strong></p>
<p>The Workbench edition which includes Query Browser (now called SQL Development) and Administrator (now called Server Administration) is only available in beta but it the old MySQL GUI Tools have already been pulled from Downloads. So I downloaded the latest beta version of MySQL Workbench 5.2.20 and gave it a try.</p>
<p><strong>I&#8217;m sorry to say I was very disappointed.</strong></p>
<p>This is what I have found using the SQL Development part (former Query Browser)</p>
<ol>
<li>It is super slow. Doing a query that usually takes a second in the old Query Browser can take minutes! These are just simple queries and it seems the time is not the query itself or time to fetch from server that makes it slow. This alone makes it impossible to use this tool.</li>
<li>It is not intuitive. I find it hard to work with, maybe it just takes getting used to</li>
<li>Features and functions from the Query Browser are gone, for example in Query Browser it was possible to open up a new tab to run a new query, you could then switch between tabs to see the different results. In the new SQL Development you can open up new query tabs but there is only one results tab. Another thing is that it does not show how many rows were affected by your query. Yet another missing feature is the ease to edit a row, in the old Query Browser all you did was click the Edit button. In the new SQL Development you have to do a specific &#8220;EDIT&#8221; query (which is even slower than the super slow SELECT) and then go thru several &#8220;ok&#8221; screens before your edit is finally written to database. I&#8217;m also missing is the system Tray Monitor and the Migration Toolkit.</li>
</ol>
<p><strong>I know it&#8217;s only a beta so hopefully they will get these things working in the end but for now I&#8217;m going to stick to the old Query Browser.<br />
</strong></p>
<p>After some searching I found the old GUI Tools in the <a target="_blank" href="http://downloads.mysql.com/archives.php" rel="noopener noreferrer">MySQL Download Archives</a>.<br />
It seems the latest/last version of <a target="_blank" href="http://downloads.mysql.com/archives.php?p=MySQLGUITools&amp;v=5.1.12" rel="noopener noreferrer">GUI Tools was 5.1.12 and can be downloaded here.</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2010/05/mysql-workbench-query-browser-sql-development-is-super-slow.html/feed</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
		<item>
		<title>MySql.Data.MySqlClient.MySqlException: Parameter &#8216;@id&#8217; must be defined</title>
		<link>https://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html</link>
					<comments>https://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sun, 10 May 2009 00:25:38 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/?p=159</guid>

					<description><![CDATA[I found out a funny thing today. Or maybe not so funny when I think about it&#8230; The order page on one of my sites have not been working since early November, almost 6 months!! As I&#8217;m sure you understand it&#8217;s not a very busy site, but usually I get a few orders per month&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html">Continue reading <span class="screen-reader-text">MySql.Data.MySqlClient.MySqlException: Parameter &#8216;@id&#8217; must be defined</span></a>]]></description>
										<content:encoded><![CDATA[<p>I found out a funny thing today. Or maybe not so funny when I think about it&#8230;</p>
<p>The order page on one of my sites have not been working since early November, almost 6 months!! As I&#8217;m sure you understand it&#8217;s not a very busy site, but usually I get a few orders per month so I should have noticed this a long time ago&#8230;</p>
<p>The site is running on IIS/ASP.NET and MySQL server 5.0.45 using the MySQL .NET Connector and I&#8217;m using a SQL statement like this on the page:</p>
<blockquote><p>START TRANSACTION;<br />
INSERT INTO table1 (companyname,street,city,zip) VALUES (&#8216;XS Tech&#8217;,&#8217;test&#8217;,&#8217;test&#8217;,&#8217;12345&#8242;);<br />
SELECT @id:=id FROM table1 where id = last_insert_id();<br />
INSERT INTO table2 (id,contactname) VALUES (@id,&#8217;Max&#8221;);<br />
COMMIT;</p></blockquote>
<p><strong>This statement was throwing an exception error: &#8220;MySql.Data.MySqlClient.MySqlException: Parameter &#8216;@id&#8217; must be defined&#8221;<br />
</strong><br />
Since I could not really remember &#8211; ie had not properly documented &#8211; what changes I may have done to that page six months ago, it made trouble shooting a bit harder. But to make a long story short(er) &#8211; It turns out I had upgraded the MySQL .NET Connector and this was causing the error. The site was using MySql.Data.dll version 5.2.1.0. I tried to upgrade to 6.0.3.0 to no avail. But when downgrading to 5.1.4.0 it started to work just fine again.</p>
<p><strong>Finally, I  found that this was indeed a change in the .Net Connector. (I&#8217;m not sure what version number but starting from 5.2.0 would be my guess)<br />
Starting from version 5.2.2 of the Connector you should add the <code class="literal">Allow User Variables=True </code><a href="http://dev.mysql.com/doc/refman/5.0/en/connector-net-examples-mysqlconnection.html#connector-net-examples-mysqlconnection-connectionstring" target="_blank" rel="noopener noreferrer">Connection String Setting</a> in order to use User Defined Variables in your SQL statements.</strong></p>
<p>Example of Connection String:</p>
<blockquote><p>Database=testdb;Data Source=localhost;User Id=root;Password=hello;Allow User Variables=True</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html/feed</wfw:commentRss>
			<slash:comments>69</slash:comments>
		
		
			</item>
		<item>
		<title>Copy MySQL Database Structure without Data</title>
		<link>https://blog.tjitjing.com/index.php/2009/01/copy-mysql-database-structure-without.html</link>
					<comments>https://blog.tjitjing.com/index.php/2009/01/copy-mysql-database-structure-without.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Mon, 12 Jan 2009 01:42:00 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2009/01/copy-mysql-database-structure-without-data.html</guid>

					<description><![CDATA[Three easy steps to copy the structure of a MySQL database, i.e. the table definitions but no rows/records/data: 1. Create the new database, either from MySQL Query Browser (part of MySQL GUI Tools) or MySQL Command Line: CREATE DATABASE `new_database_name`; 2. Copy the database structure using the mysqldump command from a dos command prompt. Note:&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2009/01/copy-mysql-database-structure-without.html">Continue reading <span class="screen-reader-text">Copy MySQL Database Structure without Data</span></a>]]></description>
										<content:encoded><![CDATA[<p>Three easy steps to copy the structure of a MySQL database, i.e. the table definitions but no rows/records/data:</p>
<p>1. Create the new database, either from MySQL Query Browser (part of <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html" target="_blank" rel="noopener noreferrer">MySQL GUI Tools</a>) or MySQL Command Line:</p>
<p><span style="font-weight:bold;">CREATE DATABASE `new_database_name`;</span></p>
<p>2. Copy the database structure using the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html" target="_blank" rel="noopener noreferrer">mysqldump</a> command from a dos command prompt. Note: If MySQL is not in your path you will have to navigate to the MySQL bin directory, on my machine this is in C:\Program Files\MySQL\MySQL Server 5.1\bin.</p>
<p><span style="font-weight:bold;">mysqldump -d -u root -p -v original_database_name &gt; c:\temp\dbstruct.sql</span></p>
<p>3. Restore the copied database structure to your new database from the same dos command prompt as in step 2.</p>
<p><span style="font-weight:bold;">mysql.exe -uroot -p new_database_name &lt; c:\temp\dbstruct.sql</span></p>
<p>Done!</p>
<p>Some notes:<br />
&#8211; I used MySQL Server 5.1 when testing this but should work also with earlier versions. If you can or cannot get it to work with another version please add a comment.<br />
&#8211; In this example I used root as user but any user with read and create permissions would work.</p>
<p><em>[Edit: Use mysqldump -R parameter to backup stored procedures and functions, above example would be:<br />
mysqldump -d -u root -p -v -R original_database_name &gt; c:\temp\dbstruct.sql<br />
<a href="http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html" target="_blank" rel="noopener noreferrer">Link to mysqldump in MySQL Reference Manual</a> ]</em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2009/01/copy-mysql-database-structure-without.html/feed</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>BC30560: &#8216;MySqlConnection&#8217; is ambiguous in the namespace &#8216;MySql.Data.MySqlClient&#8217;.</title>
		<link>https://blog.tjitjing.com/index.php/2008/12/bc30560-mysqlconnection-is-ambiguous-in.html</link>
					<comments>https://blog.tjitjing.com/index.php/2008/12/bc30560-mysqlconnection-is-ambiguous-in.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Mon, 01 Dec 2008 00:18:00 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[VB.NET]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2008/12/bc30560-mysqlconnection-is-ambiguous-in-the-namespace-mysqldatamysqlclient.html</guid>

					<description><![CDATA[I got this error in one of my ASP.NET web sites after uploading a new version: BC30560: &#8216;MySqlConnection&#8217; is ambiguous in the namespace &#8216;MySql.Data.MySqlClient&#8217;. It worked fine on my development machine but not on the production server. I could not figure out what it was for quite some time. Turned out I had added the&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2008/12/bc30560-mysqlconnection-is-ambiguous-in.html">Continue reading <span class="screen-reader-text">BC30560: &#8216;MySqlConnection&#8217; is ambiguous in the namespace &#8216;MySql.Data.MySqlClient&#8217;.</span></a>]]></description>
										<content:encoded><![CDATA[<p>I got this error in one of my ASP.NET web sites after uploading a new version:</p>
<p>BC30560: &#8216;MySqlConnection&#8217; is ambiguous in the namespace &#8216;MySql.Data.MySqlClient&#8217;.</p>
<p>It worked fine on my development machine but not on the production server. I could not figure out what it was for quite some time. <span style="font-weight: bold;">Turned out I had added the mysql.dll to bin directory of my project and at the same time was referencing a shared (GAC) version of the same dll</span>. I had made this and some other changes on the development machine that I had forgot about. The only thing that differed from the development and production machines was the web.config which I obviously did not check well enough.</p>
<p>Posting this here if someonelse or myself makes this stupid mistake again&#8230;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2008/12/bc30560-mysqlconnection-is-ambiguous-in.html/feed</wfw:commentRss>
			<slash:comments>21</slash:comments>
		
		
			</item>
		<item>
		<title>Import Excel Data into MySQL in 5 Easy Steps</title>
		<link>https://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html</link>
					<comments>https://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 29 Feb 2008 14:06:00 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy-steps.html</guid>

					<description><![CDATA[This is probably nothing new to many, but I spent quite some time to figure it out so I thought I&#8217;d post my notes on it. To import data from Excel (or any other program that can produce a text file) is very simple using the LOAD DATA command from the MySQL Command prompt. Save&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html">Continue reading <span class="screen-reader-text">Import Excel Data into MySQL in 5 Easy Steps</span></a>]]></description>
										<content:encoded><![CDATA[<p>This is probably nothing new to many, but I spent quite some time to figure it out so I thought I&#8217;d post my notes on it.</p>
<p><span style="font-weight: bold;">To import data from Excel (or any other program that can produce a text file) is very simple using the <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html" target="_blank" rel="noopener noreferrer">LOAD DATA command</a> from the MySQL Command prompt.</span></p>
<ol>
<li>Save your Excel data as a csv file (In Excel 2007 using Save As)</li>
<li>Check the saved file using a text editor such as Notepad to see what it actually looks like, i.e. what delimiter was used etc.</li>
<li>Start the MySQL Command Prompt (I&#8217;m lazy so I usually do this from the <a href="http://www.mysql.com/products/tools/query-browser/" target="_blank" rel="noopener noreferrer">MySQL Query Browser</a> &#8211; Tools &#8211; MySQL Command Line Client to avoid having to enter username and password etc.)</li>
<li>Enter this command:
<p>[code]LOAD DATA LOCAL INFILE &#8216;C:\\temp\\yourfile.csv&#8217; INTO TABLE database.table FIELDS TERMINATED BY &#8216;;&#8217; ENCLOSED BY &#8216;&quot;&#8217; LINES TERMINATED BY &#8216;\r\n&#8217; (field1, field2);[/code]</p>
</li>
<li>Done!</li>
</ol>
<p><span style="font-weight: bold;">Very quick and simple once you know it <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></p>
<p>Some notes from my own import &#8211; may not apply to you if you run a different language version, MySQL version, Excel version etc&#8230;</p>
<ul>
<li>TERMINATED BY &#8211; this is why I included step 2. I thought a csv would default to comma separated but at least in my case semicolon was the deafult</li>
<li>ENCLOSED BY &#8211; my data was not enclosed by anything so I left this as empty string &#8221;</li>
<li>LINES TERMINATED BY &#8211; at first I tried with only &#8216;\n&#8217; but had to add the &#8216;\r&#8217; to get rid of a carriage return character being imported into the database</li>
<li>Also make sure that if you do not import into the primary key field/column that it has auto increment on, otherwhise only the first row will be imported</li>
</ul>
<p><em>[Update: I had some trouble getting double quotation marks etc when exporting some Excel data and found a few old but <a href="http://www.mcgimpsey.com/excel/textfiles.html" target="_blank" rel="noopener noreferrer">useful Excel export macros in VBA</a>]</em></p>
<p><em>[Update: To change the list separator in Excel: <br />
1. First search your Excel file for the character you plan to use so it does not exist somewhere in your data. <br />
2. Go into Windows Control Panel + Regional and Language + Formats Tab click Additional Settings + List separator (Windows 7)]</em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html/feed</wfw:commentRss>
			<slash:comments>146</slash:comments>
		
		
			</item>
		<item>
		<title>Partial Restore of Mysqldump Backup</title>
		<link>https://blog.tjitjing.com/index.php/2008/01/partial-restore-of-mysqldump-backup.html</link>
					<comments>https://blog.tjitjing.com/index.php/2008/01/partial-restore-of-mysqldump-backup.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 04 Jan 2008 13:41:00 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2008/01/partial-restore-of-mysqldump-backup.html</guid>

					<description><![CDATA[Just recently I started making backups of my MySQL databases using mysqldump.I have a small batch/command file running on my Windows based MySQL Server, scheduled to every night backup all of my databases to a file named backup_all_dbs.sql: &#8220;C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump&#8221; &#8211;all-databases -u username &#8211;password=&#8221;password&#8221; > c:\backup\%DATE%\Backup_MySQL\backup_all_dbs.sql A few weeks ago I finally upgraded&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2008/01/partial-restore-of-mysqldump-backup.html">Continue reading <span class="screen-reader-text">Partial Restore of Mysqldump Backup</span></a>]]></description>
										<content:encoded><![CDATA[<p>Just recently I started making backups of my MySQL databases using <a target="_blank" href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html" rel="noopener noreferrer">mysqldump</a>.<br />I have a small batch/command file running on my Windows based MySQL Server, scheduled to every night backup all of my databases to a file named backup_all_dbs.sql:</p>
<blockquote><p>&#8220;C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump&#8221; &#8211;all-databases -u username &#8211;password=&#8221;password&#8221; > c:\backup\%DATE%\Backup_MySQL\backup_all_dbs.sql</p></blockquote>
<p>A few weeks ago I finally upgraded my MySQL server from 4.1 to 5.0. For once I did <a target="_blank" href="http://dev.mysql.com/doc/refman/5.0/en/upgrade.html" rel="noopener noreferrer">everything by the book</a> which included backing up all my databases using the backup tool in MySQL Administrator, installing the new server version and then restoring all databases.</p>
<p>Today however I just realized that somehow two tables in one of the databases did not get backed up and hence not restored. Fortunately I still had the nightly backup from the day before upgrading. </p>
<p><span style="font-weight:bold;">So I thought I&#8217;d just do a selective restore from the mysqldump file using MySQL Administrator (<a target="_blank" href="http://dev.mysql.com/downloads/gui-tools/5.0.html" rel="noopener noreferrer">part if the MySQL GUI Tools</a>) Turns out MySQL Administrator does not read files created with mysqldump.<br />And worse: a quick Google reveals that mysqldumps cannot be partially restored <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span></p>
<p>My next couple of hours I spent installing and uninstalling various text editors that could open my 500+MB backup file from mysqldump. I finally found one that could, even though it took a while&#8230; (using a Windows Vista machine with 2GB RAM) &#8211; <a target="_blank" href="http://www.notetab.com/" rel="noopener noreferrer">NoteTab Light 5.5</a> (freeware)</p>
<p>Using this I opened the backup file created with mysqldump and sure enough it was a text file containing SQL statements (too bad MySQL Administrator could not open it, hopefully it will in a future version). <br />I simply deleted the SQL statements for all databases except the one I wanted to partially restore. Then I restored it on my development machine using this command:</p>
<blockquote><p>&#8220;C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe&#8221; -uusername -p dbname < c:\backup\2007-12-13\backup_all_dbs.sql</p></blockquote>
<p>Important note: If you have backed up full databases (not just tables) then it seems the dbname parameter doesn&#8217;t matter, it still restores to the original database name &#8211; lucky me I did it on my development machine!</p>
<p>After the restore I did a partial backup using MySQL Administrator. Moved that backup file to my production server and did a restore using MySQL Administrator on that machine. Voìla!</p>
<p><span style="font-weight:bold;">So, to sum up:<br />1) Open your dump file in a large file text editor and delete everything except what you want to restore.<br />2) On a non-production machine (recommended) do a restore.<br />3) Make a partial backup using MySQL Administrator from your non-production machine<br />4) Restore the partial backup using MySQL Administrator on your production server. </span></p>
<p>Job done, finally I can get back to work!</p>
<p>Of course you can skip step 2 and 3 (and/or just restore the specific tables you want) if you like living dangerously <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Happy New Year!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2008/01/partial-restore-of-mysqldump-backup.html/feed</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Unable to convert MySQL date/time value to System.DateTime</title>
		<link>https://blog.tjitjing.com/index.php/2007/04/unable-to-convert-mysql-datetime-value.html</link>
					<comments>https://blog.tjitjing.com/index.php/2007/04/unable-to-convert-mysql-datetime-value.html#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Mon, 16 Apr 2007 15:39:00 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2007/04/unable-to-convert-mysql-datetime-value-to-systemdatetime.html</guid>

					<description><![CDATA[After switching from MySQL ODBC driver to the .NET connector I have been getting this error: Unable to convert MySQL date/time value to System.DateTime. This is when a DATETIME or DATE field contains an invalid value. It turns out that 0000-00-00 which I have used as default value in a DATE column is considered an&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2007/04/unable-to-convert-mysql-datetime-value.html">Continue reading <span class="screen-reader-text">Unable to convert MySQL date/time value to System.DateTime</span></a>]]></description>
										<content:encoded><![CDATA[<p>After switching from MySQL ODBC driver to the .NET connector I have been getting this error: Unable to convert MySQL date/time value to System.DateTime.</p>
<p><strong>This is when a DATETIME or DATE field contains an invalid value. It turns out that 0000-00-00 which I have used as default value in a DATE column is considered an invalid date. Instead NULL should be used when date/time is not set.</p>
<p>The one solution I found is to add Allow Zero Datetime=True to the connection string, this allows for 0000-00-00 00:00:00 in a DATETIME column. Just add it at the end of your connection string so it looks something like this:<br /><code>&lt;add key="connectionString" value="Database=your_db;Data Source=localhost;User Id=root;Password=password;Allow Zero Datetime=True;"/&gt;</code></strong></p>
<p>This however did not seem to work 100% for my code.<br />In VB.NET I was using this piece of code to check if the valid_until field (of type DATE) is set or not:<br /><code>If ("" & myDataReader("valid_until")) = "" Then ... </code></p>
<p>I was concatenating to an empty string istead of using .ToString() because this (if I remember it correctly) would catch both NULL and 0000-00-00 values (both would evaluate to empty string).<br />Now instead I got this error message: Conversion from type &#8216;MySqlDateTime&#8217; to type &#8216;String&#8217; is not valid.</p>
<p>With ODBC, 0000-00-00 used to evaluate to empty string, but using the .NET connector with the connection string work around it returns the actual value, so I have to check for the zeroes instead. So, the solution to my problem is of course to use the proper .ToString function and check for both &#8220;0000-00-00&#8221; and empty string returned for null value (or even better &#8211; use the proper IsDBNull function). </p>
<p><strong>Another way besides using the connection string workaround is of course to fix the data. </strong></p>
<ul>
<li>First check the data definitions in your databases to make sure it does not default to 0000-00-00 (for data type DATE) or 0000-00-00 00:00:00 (for data type DATETIME). I&#8217;m still running MySQL server version 4 but I think that on version 5, using 0000-00-00 as default value is no longer valid.</li>
<p></p>
<li>Then update the data. An SQL statement to update a column of type DATE would typically look like this for a column named valid_until:<br /><code>UPDATE your_table SET valid_until=null WHERE valid_until LIKE '0000-00-00';</code></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2007/04/unable-to-convert-mysql-datetime-value.html/feed</wfw:commentRss>
			<slash:comments>17</slash:comments>
		
		
			</item>
		<item>
		<title>.NET and MySQL in Five Easy Steps</title>
		<link>https://blog.tjitjing.com/index.php/2007/04/net-and-mysql-in-five-easy-steps.html</link>
					<comments>https://blog.tjitjing.com/index.php/2007/04/net-and-mysql-in-five-easy-steps.html#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Thu, 05 Apr 2007 08:53:00 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.tjitjing.com/index.php/2007/04/net-and-mysql-in-five-easy-steps.html</guid>

					<description><![CDATA[I&#8217;ve been using the MySQL ODBC driver for a long time now in my ASP.NET projects (as posted about here). But today when I was about to start a new project on my new Vista machine I thought I&#8217;d check if anything new had emerged the last years when it comes to MySQL drivers for&#8230; <a class="more-link" href="https://blog.tjitjing.com/index.php/2007/04/net-and-mysql-in-five-easy-steps.html">Continue reading <span class="screen-reader-text">.NET and MySQL in Five Easy Steps</span></a>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been using the MySQL ODBC driver for a long time now in my ASP.NET projects (<a target="_blank" href="http://www.tjitjing.com/blog/2006/05/how-to-access-mysql-from-net-aspnet.html" rel="noopener noreferrer">as posted about here</a>). But today when I was about to start a new project on my new Vista machine I thought I&#8217;d check if anything new had emerged the last years when it comes to MySQL drivers for .NET &#8211; and not too surprisingly there is now (probably been there for a loooong time) an ADO.NET driver called <a target="_blank" href="http://www.mysql.com/products/connector/" rel="noopener noreferrer">ADO.NET Driver for MySQL Connector/NET</a>. </p>
<p><strong>So this post is on how to get it going, it&#8217;s very straight forward. </strong><br />This is tried on Vista with Visual Studio 2005 SP1 and the <a target="_blank" href="http://support.microsoft.com/Default.aspx?kbid=929470" rel="noopener noreferrer">Visual Studio 2005 Service Pack 1 Update for Windows Vista</a> using the ADO.NET Driver for MySQL (Connector/NET) version 5.0.6.</p>
<p>1) Download and install (using the included installer) the <a target="_blank" href="http://www.mysql.com/products/connector/" rel="noopener noreferrer">ADO.NET Driver for MySQL Connector/NET</a>.</p>
<p>2) Create or open a project in Visual Studio 2005. I&#8217;m using a VB.NET console project in my example.</p>
<p>3) Go to Project + Add Reference&#8230;<br />On the .NET tab find and hilite MySQL.Data and then click Ok.<br />(It seems this step can be skipped sometimes&#8230;)<br /><em>[Update: In an ASP.NET project go to Website + Add Reference]</em></p>
<p>4) Go to Project + YourProject Properties&#8230; + References Tab<br />Under Imported Namespaces check MySql.Data.MySqlClient and MySql.Data.Types and save.<br /><em>[Update: In an ASP.NET project open web.config and add as namespace under configuration &#8211; system.web &#8211; pages &#8211; namespaces]</em></p>
<p>5) Write your code and run it. Here is an example to get you started:<br /><code>  <br />        Dim myConnectionString As String = "Database=TestDB;Data Source=localhost;User Id=TestID;Password=TestPwd"<br />        Dim myConnection As New MySqlConnection(myConnectionString)<br />        Dim myCommand As New MySqlCommand("SELECT * FROM testtable", myConnection)<br />        Dim myDataReader As MySqlDataReader<br />        myConnection.Open()<br />        myDataReader = myCommand.ExecuteReader<br />        While myDataReader.Read<br />            Console.WriteLine(myDataReader("testcolumn"))<br />        End While<br />        myDataReader.Close()<br />        myConnection.Close()<br /></code><br />More examples can be found in <a target="_blank" href="http://dev.mysql.com/doc/refman/5.0/en/connector-net-examples.html" rel="noopener noreferrer">the manual from MySQL</a>.</p>
<p>Note: If your accessing your MySQL server on another machine, i.e. not as localhost, you need to make sure the firewall on the server allows access on TCP port 3306. If the server is using Windows firewall just simply go into Control Panel &#8211; Windows Firewall &#8211; Exceptions Tab click Add Port. (Just make sure you remember to disable the port again after you are done testing!)</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tjitjing.com/index.php/2007/04/net-and-mysql-in-five-easy-steps.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
