Submitting using Custom Code

M

mdsmitty

At the moment, my form will not allow me to submit back to my SQL data
source. When I go to Submitting Forms, the "Database" selection is not
available. Is there a way to write VBScript as a work around? If so, does
anyone know how or what to write as I am very new to writing VBScript.

I have read that there is an issue with having "long data types". Is it
possible that I will need to change my SQL table properties?

Thanks
 
M

mdsmitty

I have...I created my form using a data source. I believe that the issue is
actually with the "data type" properties within my SQL database. I tested a
database that was working with the submit and then the one I was trying to
work with and matched the "data types" which now allows me to submit. I now
have another error resulting while testing my form in the Preview mode...

InfoPath cannot submit the form.
An error occurred while the form was being submitted.

[0x80040E2F][Microsoft OLE DB Provider for SQL Server] Violation of PRIMARY
KEY constraint 'PK__Account__072CF7AA'. Cannot insert duplicate key in object
'Account'.
[0x80040E2F][Microsoft OLE DB Provider for SQL Server] The statement has
been terminated.

In this instance, I am trying to add a new entery into the database tables
"on the fly". It actually worked the first time but I got the error
everytime after that. I don't have any problems with existing records in the
Database.
 
S

Scott L. Heim [MSFT]

Hi,

Try to add the same *identical* record manually as you were trying with
InfoPath - this is a SQL Server primary key violation error so you should
probably get the same error manually.

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

mdsmitty

Question...when InfoPath Submits to the database, is it updating or inserting
into the database?
 
H

halkar

To my understanding it inserts, use custom code for updates and inserts
with caluse "where" etc.

What is the Account column in your database that you are using as
Primary Key? Is it an Identity column? Is it auto incremented? You
might need to reseed the identity if you have manually removed any
records from the table by using DBCC CHECKINDENT(tablename, reseed, 1)
(The number 1 is the number you want to auto increment to start or
continue from)

If none of the conditions are true for you, you can try adding a new ID
column and use it as the Primary Key.
 
M

mdsmitty

Thanks for the help gentlemen. I needed to change my primary key. I added a
new column called info_number, auto incremented, and used it as the primary
key. Now I can add new records to my blank table which is my objective.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top