[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

String problem with SQL Server

Posted on 2004-09-21
5
Medium Priority
?
727 Views
Last Modified: 2012-06-21
I have a string problem with SQL server, I have code that dynamically generates SQL commands from XML data, one of which is:



query = query.Replace("???TIMESTAMP???", "'" + DateTime.Now.ToString("yyyyMMdd") + "'");

{"ERROR [07002] [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error" }      System.Exception

INSERT INTO region_info(prefix, region, last_update) VALUES ('907209', 'Alaska-Juneau', '20040921');

Now, the replace is creating the query of the above line.  When I cut and paste that line from the exception text into the Query Analyazer, it runs fine.  I'm misisng my problem somewhere.
0
Comment
Question by:jjacksn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Assisted Solution

by:tzxie2000
tzxie2000 earned 750 total points
ID: 12115354
could you show a little more code about it?

I think it may be the different of acceptable datetime between Query Analyazer and C#
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12115394
query = query.Replace("???TIMESTAMP???", "'" + DateTime.Now.ToString("yyyyMMdd") + "'");

after this line what does query contain?

0
 
LVL 5

Author Comment

by:jjacksn
ID: 12115870
exactly "INSERT INTO region_info(prefix, region, last_update) VALUES ('907209', 'Alaska-Juneau', '20040921');"
0
 
LVL 15

Accepted Solution

by:
praneetha earned 750 total points
ID: 12116050
hardcode query="INSERT INTO region_info(prefix, region, last_update) VALUES ('907209', 'Alaska-Juneau', '20040921');"

and see if that works

is " at the start and end part of query-

i mean is query=" "insert into.... " "
0
 
LVL 5

Author Comment

by:jjacksn
ID: 12116525
nm, it was a different problem.  
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question