Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: cross-post Pin
AssemblySoft6-Nov-07 5:19
AssemblySoft6-Nov-07 5:19 
GeneralRe: cross-post Pin
led mike6-Nov-07 5:40
led mike6-Nov-07 5:40 
GeneralRe: cross-post Pin
AssemblySoft6-Nov-07 5:50
AssemblySoft6-Nov-07 5:50 
GeneralRe: cross-post Pin
led mike6-Nov-07 6:07
led mike6-Nov-07 6:07 
GeneralRe: cross-post Pin
AssemblySoft6-Nov-07 6:17
AssemblySoft6-Nov-07 6:17 
GeneralRe: cross-post Pin
led mike6-Nov-07 10:32
led mike6-Nov-07 10:32 
AnswerRe: C# and simple SOAP Pin
Ennis Ray Lynch, Jr.5-Nov-07 9:56
Ennis Ray Lynch, Jr.5-Nov-07 9:56 
QuestionSQL Error converting data type varchar to numeric Pin
ortaparmak5-Nov-07 5:30
ortaparmak5-Nov-07 5:30 
Hello,

I am a hobby programmer, writing a small office automation program for my office (translation agency). It's a small database application with several tables on MS SQL Server 2005 (Express). There is a Jobs table which includes individual Project items (i.e. when a translation project includes multiple language pairs, for instance XXXX_EN-TR and XXXX-DE-TR (where XXXX is ProjectID) these individual items (jobs) are written in Jobs table with a foreign key to Projects table's ProjectID).

Upon a button click application should write to Jobs table with following:

string addNewJobQuery = "INSERT INTO Jobs (ProjectID, FileName, SourceLanguage, TargetLanguage, Type, CharCount, PageCount, ApplicableRate, QuotedOn)" + " VALUES (\'" + projectID + "\', \'" + fileName + "\', \'" + srcLangID + "\', \'" + trgLangID + "\', \'" + typeID + "\', \'"  + charCount + "\', \'" + pageCount + "\', \'" + applicableRate + "\', \'" + quotedOn + "\'); SELECT SCOPE_IDENTITY()";<br />


Above string includes all mandatory (i.e. where null not allowed) fields of Jobs table and data submitted with this query is appropriate (i.e. decimal is sent to SQL for all decimal fields, Int64 sent for all long fields etc.). But it just don't work. It shoots me an exception "e.message = Error converting data type varchar to numeric."
Following is a list of variables I sent in my last attempt:

ProjectID = 34051 (valid, ProjectID should be long at SQL and Int64 in C# code)
fileName = "D:\\UI\\...\\FileName.doc" (this is string in c# code and text at SQL; shouldn't be this one)
srcLangID = 0 (bigint at SQL, Int64 in c#; this is foreignkey to LanguageID in Languages table; correct)
trgLangID = 1 (biginy at SQL, Int64 in c#; this is foreignkey to LanguageID in Languages table; correct)
typeID = 1 (SQL: bigint, C# Int64, correct - foreignkey to Services tables ServiceID, which is also long)
charCount = 71325 (bigint at SQL, Int64 in C# code. this shouldn't be problem either)
pageCount = 71.325 (decimal at SQL and decimal in C# code)
applicableRate = 25 (alo decimal)
quotedOn = 05.11.2007 17:40:15 (this I obtain with DateTime.Now; should not be problem UNLESS...)

Here is what I seriously suspect; my OS is Turkish language, SQL Server Express is English, Visual Studio is also English. Could it be:
1) DateTime returning different format date/time (. instead of /); OR
2) Different decimal separators (. instead of ,)

OH, wait, when I type above string (removing quotemarks and paranthesis ofcourse) in a query, it all works fine... But in C# it just won't.

Could anyone come up with a hint? Thanks in advance & Kind Regards



Haluk
AnswerRe: SQL Error converting data type varchar to numeric Pin
Rob Philpott5-Nov-07 5:53
Rob Philpott5-Nov-07 5:53 
GeneralRe: SQL Error converting data type varchar to numeric Pin
ortaparmak5-Nov-07 7:13
ortaparmak5-Nov-07 7:13 
AnswerRe: SQL Error converting data type varchar to numeric Pin
snorkie5-Nov-07 5:56
professionalsnorkie5-Nov-07 5:56 
GeneralRe: SQL Error converting data type varchar to numeric Pin
ortaparmak5-Nov-07 7:06
ortaparmak5-Nov-07 7:06 
GeneralRe: SQL Error converting data type varchar to numeric Pin
snorkie5-Nov-07 7:12
professionalsnorkie5-Nov-07 7:12 
GeneralRe: SQL Error converting data type varchar to numeric Pin
ortaparmak5-Nov-07 7:41
ortaparmak5-Nov-07 7:41 
GeneralRe: SQL Error converting data type varchar to numeric Pin
snorkie6-Nov-07 5:13
professionalsnorkie6-Nov-07 5:13 
AnswerRe: SQL Error converting data type varchar to numeric Pin
Pete O'Hanlon5-Nov-07 9:38
mvePete O'Hanlon5-Nov-07 9:38 
GeneralRe: SQL Error converting data type varchar to numeric Pin
ortaparmak5-Nov-07 11:41
ortaparmak5-Nov-07 11:41 
QuestionIs Regex faster? Pin
error14085-Nov-07 5:24
error14085-Nov-07 5:24 
AnswerRe: Is Regex faster? Pin
Ilya Verbitskiy5-Nov-07 5:29
Ilya Verbitskiy5-Nov-07 5:29 
AnswerRe: Is Regex faster? Pin
Colin Angus Mackay5-Nov-07 5:30
Colin Angus Mackay5-Nov-07 5:30 
AnswerRe: Is Regex faster? Pin
DavidNohejl5-Nov-07 5:48
DavidNohejl5-Nov-07 5:48 
AnswerRe: Is Regex faster? Pin
Pete O'Hanlon5-Nov-07 9:28
mvePete O'Hanlon5-Nov-07 9:28 
GeneralRe: Is Regex faster? Pin
error14085-Nov-07 21:53
error14085-Nov-07 21:53 
GeneralRe: Is Regex faster? Pin
Pete O'Hanlon5-Nov-07 23:16
mvePete O'Hanlon5-Nov-07 23:16 
QuestionWeb Service Client / Using Non-Passed In Parameters Pin
Jeremy A. Cunningham ~ AltTech5-Nov-07 5:18
Jeremy A. Cunningham ~ AltTech5-Nov-07 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.