Inserting a record in a Microsoft Access database table but failing miserably

I must be doing something wrong, but I can’t figure it out. I have simplified the process, so I am only inserting 1 field to create a new record in an Access DB table. I get the subject out of an email and add it into a new rec in a table. The email part works fine, and I assign the subject to a variable ie.

strSubject = item.subject

I can then display the string strSubject in a message box.

I then connect to the Access DB

ConnectionString: “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\DATA\aSmallWerxs\BMS.accdb”

ProviderName: “System.Data.OleDb”

I test the connection and it is OK.

I then do a Execute Non Query to insert the record ie.:

Existing Connection: BMSConnect

Parameters:

  • Name: strSubject
  • Direction: In
  • Type: String
  • Item: Subject

Sql: “INSERT INTO HDTicket_tbl(Title) values(@strSubject)”

So when I run the program a new record is created but strSubject is not passed into the table.

If I change it so I pass in item.subject the subject is not passed in. The only way the data is added is if I actual manually put the data in the SQL statement ie:

Sql: “INSERT INTO HDTicket_tbl(Title) values(‘Problem backing up application’)”

Thanks for any help

Hi,

Welcome to Uipath Forum. We are here to help you solve the issue :slight_smile:

The issue seems to be with quotes. Since the entire string including the variable name is enclosed within quotes, it might consider it as hardcoded value.

Try this,
“INSERT INTO HDTicket_tbl(Title) values(" + strSubject +")”

1 Like

Thanks Arun,
I solved the problem, it was the parameter collection and the SQL statement. This is the full SQL statement when I added in the rest of the fields:
“INSERT INTO HDTicket_tbl(Title, Client_FK, IssueDate, IssueTime, Status_FK, IssueDesc, EmailName) values(@Title, @Customer, ?IssueDate, ?IssueTime, ?Status, ?MailMessage, ?MailFrom)”

Sorry about the question marks, but the system thinks I am referencing more than three people in a post and it wouldn’t let me reply.

Again thanks for your help.