I have an ASP.net website that has been working fine. Some of what is displayed is retrieved from a MySQL database. For example, news items.
Recently where a date was retrieved and a URL consructed from info from the db suddenly started returning System.Byte[].
On googling this seemed to be related to a version of the odbc. After a lot of to-ing and fro-ing with the site's support, the odbc is the latest and MySQL is v5. The problem still remains.
All the while my "production" machine is an ancient laptop running win2000 (latest odbc 3.51 and MySQL5) everything works fine.
I have discovered however that on my vista desktop (latest odbc, MySQL) the problem also happens.
As dealing with the website support is like wading through treacle I thought I should try to fix it on the vista machine and I might then have an idea of what to do with the live site.
A workaround may be changing my code.
Still reading?
the c# code is posted below for one page where the problem occurs. The fields that show as System.Byte[] are the modified date and the "read more" link. Both have string operations applied to them. Removing this formatting results in the correct raw data being retrieved.
But one other field has string operations but is ok. The two that error involve a date and the other an int.
We use both and over the last few years I have found that the MySQL one is getting very stable while the odbc one is getting worse! We even get odbc errors know that require us to restart the server.
There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
Thanks for your suggestion. I will try to get the hosts to implement the .net connector anyway.
However, as often happens, describing the problem has set my mind off in another direction in order to fix this.
My thoughts were that a stored procedure might do the trick. If it only returned strings there should not be a problem. My thinking perhaps wasn't too clear here but following this approach I discovered some flaws in my query. Presumably being "forgiven" under Win2000.
The query that now reside in my stored proc is as follows
SELECT
ID,
head,
IF(LENGTH(item)> 50, CONCAT(SUBSTRING(item,1,50)," ..."),item) AS item,
CONCAT("<A HREF=\"newsitem.aspx?from=ai&id=",Cast(ID as char(4)),"\">Read item</a>") AS ReadItem,
DATE_FORMAT(modified,"%D %b %y") AS modified,
forcetop,
forceverytop,
modified as sortdate
FROM newsitems WHERE deleted = 0 ORDER BY sortdate DESC ;
The third field "item" has the single quotes replaced with double quotes.
The fourth likewise with escaped double quotes and, perhaps more importantly, a cast of the integer ID.
Fifth field, a proper format of the date rather than just using substring.
so with this in a sp the page works! here I don't know if the same as in line sql works but I don't care.
just need to fix all the other bits than don't work now.
ODBC is not as optimized as .NET data providers, especially when dealing with SQL Server, so you should always go that direction when there is the opportunity.
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment.
To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB.
To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…