473,396 Members | 1,772 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,396 software developers and data experts.

ADO .Net Timing Issue

Good Morning,

I get the following error when trying to add a record to and access table:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll. The code runs fine as long as I wait a second or two
between each occurance of it running, but if I try to add the records to fast
the error is generated. I have put a debug.write line at the begining and
end of the code and it is finishing it before the next write starts so does
any one know what the issue is?
Here is my code:
Dim strHolderTN = "'" & strTrailerNumber & "'"
Dim strHolderCN = "'" & strContainerNumber & "'"

Dim strSQL As String = "Insert into tblLotTrace(TrailerKey,
CSerialNumber, DockDoor) values(" & strHolderTN & "," & strHolderCN & "," &
intDoor & ")"
Debug.Write(strSQL)
'Stop
Dim objcommand As New OleDbCommand(strSQL, New
OleDbConnection(gsSQLData))
Debug.Write(objcommand.ToString)
objcommand.Connection.Open()

'Dim cmdLotTrace As OleDbCommand = New OleDbCommand(strSQL,
conLotTrace)
'objcommand.Connection.Open()
objcommand.ExecuteNonQuery()
objcommand.Connection.Close()
objcommand.Dispose()
objcommand = Nothing
Thanks in advance!
Jul 21 '05 #1
1 1188
Dkalsow,

I don't see the problem direct, the best thing you can do is to set your
code in a try and catch block.

The most simple one can be

Dim cmdLotTrace As OleDbCommand = New OleDbCommand(strSQL, conLotTrace)
try
objcommand.Connection.Open()
objcommand.ExecuteNonQuery()
catch ex as oledb.exception
messagebox.show(ex.tostring)
catch ex as exception
messagebox.show(ex.tostring)
finally
objCommand.Connection.dispose
end try

And do not those other closes and setting to nothing, they should not be
needed, maybe is even the error in that, that deep I did not look.

Mostly is done instead of your

Dim conn as new oledbconnection = "connectionstring"
Dim objcommand As New OleDbCommand(strSQL, conn)

And than use instead of your objCommand.Connection

conn.open and conn.dispose.

I think that it is next time better when you ask this question in the
newsgroup

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

There is as well the newsgroup
microsoft.public.dotnet.languages.vb

Where this kind of questions are as well done, however the first one it
better for this question.

I hope this helps anyway?

Cor

"dkalsow" <dk*****@discussions.microsoft.com>
Good Morning,

I get the following error when trying to add a record to and access table:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred
in
system.data.dll. The code runs fine as long as I wait a second or two
between each occurance of it running, but if I try to add the records to
fast
the error is generated. I have put a debug.write line at the begining and
end of the code and it is finishing it before the next write starts so
does
any one know what the issue is?
Here is my code:
Dim strHolderTN = "'" & strTrailerNumber & "'"
Dim strHolderCN = "'" & strContainerNumber & "'"

Dim strSQL As String = "Insert into tblLotTrace(TrailerKey,
CSerialNumber, DockDoor) values(" & strHolderTN & "," & strHolderCN & ","
&
intDoor & ")"
Debug.Write(strSQL)
'Stop
Dim objcommand As New OleDbCommand(strSQL, New
OleDbConnection(gsSQLData))
Debug.Write(objcommand.ToString)
objcommand.Connection.Open()

'Dim cmdLotTrace As OleDbCommand = New OleDbCommand(strSQL,
conLotTrace)
'objcommand.Connection.Open()
objcommand.ExecuteNonQuery()
objcommand.Connection.Close()
objcommand.Dispose()
objcommand = Nothing
Thanks in advance!

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Timo | last post by:
When content is transferred from a hidden IFRAME (which has fetched data from a database) to a DIV in the main document, how can a script determine that the DIV has been completely populated before...
3
by: Russell | last post by:
I have a quirky issue that I believe involves timing and only 2 hairs left to pull. I have a modal dialog that is an IFrame. The IFrame contains another window - which contains the appropriate...
2
by: Don | last post by:
From within the "main" frame, using JS, I'm trying to copy a couple variables and arrays from the "header" frame into the "main" frame. I've incorporated a couple "alert" statements to test the...
3
by: pbbriggs | last post by:
I will try to be as descriptive as possible, but this error has me stumped and I am not sure what relevant info to include.... I am running Access XP on a Windows XP machine. I initially began...
7
by: Jacob Barnett | last post by:
Access 2000 main report does not display subreport data in preview and may or may not print... sometimes. Usually, the entire report is fine. The behavior does not seem to depend on particular...
4
by: Brian Hanson | last post by:
Hi, I have a problem that is sporadic and am thinking it may come down to a timing issue. I have an asp.net (vb) app that used the system.io.file.copy method to copy a .pdf file from a network...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
4
by: Nebulus | last post by:
We've got a website that's designed in classic ASP. While it's a good product, the original design was badly done, and I've inherited a monster. At some point last week, users began calling in...
2
by: julie.siebel | last post by:
Google apparently ate my original post to this (grr) so this'll be a bit more vague than the initial post, but...*sigh*. Javascript is not my forte, and I apologize for the acky-ness of the...
0
by: Daniel Fetchinson | last post by:
On 4/15/08, Daniel Fetchinson <fetchinson@googlemail.comwrote: BTW, using the following ###################################################################### # CODE TO TEST BOTH...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.