Solved

String problem with SQL Server

Posted on 2004-09-21
5
712 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
  • 2
  • 2
5 Comments
 
LVL 5

Assisted Solution

by:tzxie2000
tzxie2000 earned 250 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 250 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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