Writing Insert Query in uipath studio

Hello, im trying run a execute non query activity with an insert query into my database like below,

“INSERT Into user_details(User_ID, User_Name, User_Role, NIC, Mobile_Number, BranchCode)
VALUES ('”+User_ID+“‘,’”+User_Name+“', '”+User_Role+“', '”+NIC+“', '”+Mobile_Number+“', ‘“Branch_Code”’);”

it’s giving a compiler error for me that,
“String constants must end with a double quote.”
I tried to pass data through parameters also but it doesn’t pass values instead of null values.
What must be change??

Hi @KavinduPerera,

Can you try like this.

“INSERT Into user_details(User_ID, User_Name, User_Role, NIC, Mobile_Number, BranchCode)
VALUES (” + “‘User_ID’” + “,” + “‘User_Name+’” + “,‘+User_Role+’”+ “,‘NIC’” + “,‘Mobile_Number’” + “,‘Branch_Code’)”

1 Like

Hi @KavinduPerera

Welcome to Uipath community

You have issue with Double Quotation. Try to update the Double Quote "

Check out this below query

"INSERT Into user_details(User_ID,User_Name,User_Role,NIC,Mobile_Number,BranchCode) VALUES ('"+User_ID+"','"+User_Name+"','"+User_Role+"','"+NIC+"','"+Mobile_Number+"','"Branch_Code"');"

Regards
Gokul

1 Like

It says cannot find the column name and yeah you’re right i have a quotation issue but can’t find where.
image

it comes the same error.


Should i change my variables in to arguement and pass into parameters in run command activity?

Hello @KavinduPerera ,

Welcome to UiPath community.

Try this query, it will helps you
INSERT Into user_details(User_ID, User_Name, User_Role, NIC, Mobile_Number, BranchCode)
VALUES (“'”+User_ID+“‘,’”++User_Name+“‘,’”+User_Role+“‘,’”+NIC+“‘,’”+Mobile_Number+“‘,’”+Branch_Code+“'”);

Happy Automation, :grinning:
Sai Krishna

1 Like

Hi @KavinduPerera,

I updated the query. Can you try this?

“INSERT Into user_details(User_ID, User_Name, User_Role, NIC, Mobile_Number, BranchCode)
VALUES (” + “'” + User_ID + “'” + “,” + “'”+User_Name+“'” +“'” + “,'” +User_Role + “,'” + NIC + “',” + Mobile_Number + “',” + Branch_Code +“');”

Regards
Ömer

1 Like

hi @omer.ozturk
Actually I’m new to uipath and your support is a big help now i tried your new code but it’s a new error popping up in runtime.
Sorry for the trouble :sweat_smile:

image
now it comes to this

Hello @sai_krishna_somisetty
Thank you for Replying to me
I tried your code and it comes to this runtime error
image

Just to know should i change my variables into arguements and pass it in parameter field??

Hi @KavinduPerera,

We seem to be getting closer to the solution :slight_smile:

In forum double quote syntax change a little. Can you change double quotes manually?

I cant send the real form in my Studio. In my studio, it looks like this.

Regards
Ömer

1 Like

I updated it a little bit too.

"INSERT Into user_details(User_ID, User_Name, User_Role, NIC, Mobile_Number, BranchCode)
VALUES ('" + User_ID + "','" + User_Name + "','" + User_Role + "','"  + NIC + "','" +  Mobile_Number + "','" + Branch_Code +"');"

I hope it works :slight_smile:

Regards
Ömer

2 Likes

I changed it @omer.ozturk but back to same quotation compiler error.

@KavinduPerera, my last post looks fine.

Can you try it? If problem continues, you can delete semicolon at the end.

Regards
Ömer

1 Like

@omer.ozturk Nothing changed :sneezing_face:

Do I have to pass my variables into parameters section

@KavinduPerera,

No, you dont have to give your variables to parameter section. Can you share the screenshot of your sql query part?

Regards
Ömer

@omer.ozturk

@omer.ozturk
Here’s my sql
All the columns can be null excpet user id and user name

@KavinduPerera,

The query i sent to you doesn’t get error in my studio, maybe some ’ and " placement is wrong. Are your variables is defined in UiPath Studio?.

If your answer is yes, i can send you the query from another platform. UiPath Forum changes the quotes and double quotes different.

Regards
Ömer

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