Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Query works directly but not through VB.NET (no replies)

$
0
0
I've got a query (updating a field) that executes just fine when I run it directly or from Workbench, but gives the "You have an error in your SQL syntax" error when I try to execute it from my application using Connector/.NET.

The query is:
update events set eventtype='New Name' where eventtype='Current Name';

It's constructed like this in VB:
String.Concat("update events set eventtype='", NewName, "' where eventtype='", CurrentName, "';")

An odd thing is that VB replaces the apostrophes around the first field, but not the second field, with quotation marks. I have no idea why. But the query works with either quotes or apostrophes when I do it directly.

And the table:
CREATE TABLE `events` (
  `EventSysNum` int(6) unsigned zerofill NOT NULL DEFAULT '000000',
  `EventDate` date NOT NULL,
  `EventType` varchar(20) DEFAULT NULL,
  `TempMax` int(2) DEFAULT NULL,
  `TempMin` int(2) DEFAULT NULL,
  `HumidityMax` int(3) unsigned DEFAULT NULL,
  `HumidityMin` int(3) unsigned DEFAULT NULL,
  `Wind` tinyint(1) DEFAULT NULL,
  `Sun` tinyint(1) DEFAULT NULL,
  `Rain` tinyint(1) DEFAULT NULL,
  `Weather` varchar(200) DEFAULT NULL,
  `Notes` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`EventSysNum`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

I'm using MySQL 5.5.15, VB.NET 2010, and Connector/.NET 6.4.4.

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>