473,320 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re-submitting click action event problem

12
Hi all,

I have a problem with my form i created. When I click the submit button, everything works fine, all data are committed to database but if the user happens to click the submit again, the following exception occurs: Any idea?
I have cleared all my parameters for the insert command.

A first chance exception of type 'System.FormatException' occurred in System.Data.dll
standby being added
4
4
at System.Data.ProviderBase.DbConnectionInternal.Open Connection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at WindowsApplication1.Form1.AddCompanyStandby() in C:\Documents and Settings\Root\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplicati on1\Form2.vb:line 305
0
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
at System.Data.ProviderBase.DbConnectionInternal.Open Connection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at WindowsApplication1.Form1.AddClientStandbyOvertime () in C:\Documents and Settings\Root\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplicati on1\Form2.vb:line 120
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
Nov 11 '08 #1
4 1030
Frinavale
9,735 Expert Mod 8TB
A FormatException is thrown in the case when the format of an argument doesn't meet the parameter specifications of the invoked method.

Check to make sure that you are properly opening your database connection and that you are providing it with the correct information the second time you submit the data.

-Frinny
Nov 11 '08 #2
balabaster
797 Expert 512MB
First chance exceptions can be a pain, but they're mostly cosmetic. Wrap the submit functionality in a try{} catch{} if the exception thrown is anything other than a first chance exception then handle it otherwise generally speaking, it can be ignored.

My initial gut feeling in cases where following the same submit process twice causes an exception is that the submit uses the current open connection which is then closed and disposed. If the submit button is clicked again, it attempts to continue the same process - except this time, the connection doesn't exist - thus causing your exception. Of course, the first time, the connection already existed and was in an open state... the second time, the connection was killed by the submit process the first time around... and thus, your error occurs.

If we could see the code relevant to the process, it would be helpful in deducing the cause of your exception...
Nov 12 '08 #3
kpeeroo
12
Thanks guys

Yes I surrounded the code of my submit portion with try catch clause and I found out the error. There was one of my text boxes which was not supplying the correct format in which the method was expecting it to be thus raising that exception. But initially, as i dont have much experience in .NET I thought we needed some other piece of code to allow double submitting actions!

Continuing the discussion, how then would you guys prevent the user from submitting the same data twice to the database by clicking submit button twice? Am using an application form not web form. any suggestions? cheers...
Nov 12 '08 #4
Frinavale
9,735 Expert Mod 8TB
Thanks guys

Yes I surrounded the code of my submit portion with try catch clause and I found out the error. There was one of my text boxes which was not supplying the correct format in which the method was expecting it to be thus raising that exception. But initially, as i dont have much experience in .NET I thought we needed some other piece of code to allow double submitting actions!

Continuing the discussion, how then would you guys prevent the user from submitting the same data twice to the database by clicking submit button twice? Am using an application form not web form. any suggestions? cheers...
You can disable the submit button using JavaScript once the content has been submitted. This will prevent them from submitting the data while it's being processed. Be aware that once the page posts back to the browser the button will be recreated, therefore it will no longer be disabled. If you want to permanently disable the button (for the time of the usage) you'll have to also disable the button in your server side code (set a flag indicating that it should remain disabled).

There are a a few peculiarities when disabling buttons through JavaScript though. ASP is automatically configured to ignore any disabled content, and so your button will not actually work once it's disabled. There is a property that allows you to submit disabled input though....I just can't remember it off the top of my head.

The trend these days is to place a <div> on top of your content once the page is submitted (css opacity set to let the content show through). This will disable all of the content (including DropDownLists etc) because everything will be behind the <div>... it also lets you display a message saying the data's being processed. This also has to be done using JavaScript.

-Frinny
Nov 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
1
by: Brian | last post by:
I have an array like this: $events = array( array( '2003-07-01', 'Event Title 1', '1' //ID Number (not unique) ), array( '2003-07-02',
1
by: Clarice Almeida Hughes | last post by:
tenho um index onde tenho o link pro arq css, como sao visualizados pelo include todas as paginas aderem ao css linkado no index. so q eu preciso de alguns links com outras cores no css, o q devo...
2
by: Frans Schmidt | last post by:
I want to make a new database with several tables, so I did the following: <?php CREATE DATABASE bedrijf; CREATE TABLE werknemers (voornaam varchar(15), achternaam varchar(20), leeftijd...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.