PC Review


Reply
Thread Tools Rate Thread

ADO 2.8 Slow Update Problem with VB.NET 2003 and Access2003

 
 
Tony Upchurch
Guest
Posts: n/a
 
      12th Apr 2005
Hi Everyone,

I am having a problem using ADO 2.8 with VB.NET. I have one function that opens an Access 2003 recordset and updates it. Then the next function queries the same table to decide what the next id should be, but the new record is not there. If I slow down execution by stepping through the program then I can find the new record. These two actions occur in separate functions and I have done everything I can think of to force the update to occur immediately.. including, closing the recordset and setting the variable to nothing. I stuck this into a VB6 app and it ran perfectly. What is taking the update so long to complete? How can I fix this problem?

Thanks,
Tony


Here is the code: As you can see the two action occur in a loop.

Private strData() as String
Private TransNum as string


Private Sub DoMain()
ts = New StreamReader(GetAppPath() & "upload.txt")

Do While ts.Peek >= 0
strData = Split(ts.ReadLine, ",")
TransNum = GetTransNum(strData(8))
AddRecord()
Loop

End Sub


Private Function GetTransNum(ByVal TransDate As String) As String
Dim aConn As New ADODB.Connection, aRS As New ADODB.Recordset, TransNum As Integer

aConn.Open(strConn)
strSQL = "select max([Transaction Number]) as Trans from transactions where " & _
"left([Transaction Number],8) = '" & TransDate & "' and [Transaction Number] is not null"

aRS.CursorLocation = ADODB.CursorLocationEnum.adUseServer
aRS.Open(strSQL, aConn, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic)

If aRS.EOF = True Then
TransNum = 1
Else
TransNum = VBS.Right(aRS("Trans").Value, 4)
TransNum = CInt(TransNum) + 1
End If

GetTransNum = TransDate & Format(TransNum, "0000")

End Function


Private Sub AddRecord()
Dim aConn As New ADODB.Connection, aRS As New ADODB.Recordset, strSQL As String

aConn.Open(strConn)
strSQL = "select * from transactions order by [transaction number], [line number]"
aRS.CursorLocation = CursorLocationEnum.adUseServer
aRS.Open(strSQL, aConn, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic)

aRS.AddNew()
aRS("Item Number").Value = strData(0)
aRS("Serial #").Value = strData(1)
aRS("P O #").Value = strData(2)
aRS("Account Number").Value = strData(3)
aRS("Received").Value = strData(4)
aRS("Returned").Value = strData(5)
aRS("Issued").Value = strData(6)
aRS("Job #").Value = strData(7)
aRS("DateTime").Value = strData(8) & " " & strData(9)
aRS("Transaction Number").Value = TransNum
aRS.Update()
aRS.Close()

End Sub





 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Access2003 database to Access2000 format without Access2003 Hiking Microsoft Access 2 1st Oct 2006 09:38 PM
Access2003 too slow. Frank Martin Microsoft Access Getting Started 3 23rd May 2006 09:34 AM
win 2003 slow after update Steve Microsoft Windows 2000 Networking 0 18th Apr 2006 05:11 PM
access2003 queries exported in another access2003 db (empty) lost =?Utf-8?B?QW5kcmVhIENvcm5pIChzb2Z0aW50aW1lKQ==?= Microsoft Access VBA Modules 1 21st Jun 2005 05:21 PM
Frontpage 2003 Or Access2003? Chris Chandler Microsoft Frontpage 4 22nd Oct 2004 08:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 AM.