Execute Non Query: Error converting data type varchar to numeric

Execute Non Query: Error converting data type varchar to numeric.

hi uipath community!

i have a question regarding insert non query.
i have tried to using insert non query by using this query
“INSERT INTO [dbo].[PA_CTR] (CompanyCode,SAPCust_VendorCode,CustomerName,AcctType,TotalPAAmt,VirtualAcct,Assignment,DocumentNo,ReferenceKey,Currency,PaymentAmount,PartialPaymentAmount,Remarks) VALUES ('”+row(3).ToString+“’ ,'”+row(4).ToString+“’ ,'”+row(5).ToString+“’ ,'”+row(6).ToString+“’ ,'”+row(7).ToString+“’ , '”+row(8).ToString+“’ ,'”+row(9).ToString+“’ ,'”+row(10).ToString+“’ ,'”+row(11).ToString+“’ ,'”+row(12).ToString+“’ ,'”+row(13).ToString+“’ ,'”+row(14).ToString+“’ ,'”+row(15).ToString+“’ )”

when im using manual insert @ sql server it can execute with no issues
image

but when im using studio the output will be like this

Error converting data type varchar to numeric.
can anyone advise me on this one?
tqsm!

Hi @Mohamad_Izudin_Bin_Abdul

I would like to suggest you to use parameters instead of string concatenation.

Instead of:

INSERT INTO [dbo].[PA_CTR] (CompanyCode,SAPCust_VendorCode,CustomerName,AcctType,TotalPAAmt,VirtualAcct,Assignment,DocumentNo,ReferenceKey,Currency,PaymentAmount,PartialPaymentAmount,Remarks) VALUES (’”+row(3).ToString+“’ ,’”+row(4).ToString+“’ ,’”+row(5).ToString+“’ ,’”+row(6).ToString+“’ ,’”+row(7).ToString+“’ , ‘”+row(8).ToString+“’ ,’”+row(9).ToString+“’ ,’”+row(10).ToString+“’ ,’”+row(11).ToString+“’ ,’”+row(12).ToString+“’ ,’”+row(13).ToString+“’ ,’”+row(14).ToString+“’ ,’”+row(15).ToString+“’ )”

Do:

INSERT INTO [dbo].[PA_CTR] (CompanyCode,SAPCust_VendorCode,CustomerName,AcctType...) VALUES (@CompanyCode, @SAPCust_VendorCode, @CustomerName, @AcctType...)"

These parameters (@ParameterName) you define in Parameters window specifing the correct type for each one:

Much easy to read the query and you probably won’t have facing more type issues since it will do the right conversion for you.

1 Like

You’re passing all strings and apparently PA_CTR has one or more columns that is numeric.

thank you for your fast reply and help sir.i appreciate it much and it works and helps me more on debugging! thank you!

1 Like

more than one columns are numeric.anyway thanks paul for your reply!

but i want to ask the data that i want to import are from excel file that is why im using this concatenate thing.so is it still possible to use this parameters this? @ the value area how am i going to insert the certain values inside from the excel?

Then you need to format the insert query so that they’re inserted as numeric not string (varchar). The error is telling you what the problem is.

thanks @postwick appreciate it very much

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.