473,471 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MSSql VB ADODB troubles

1 New Member
I've been tasked to upgrade an old system and there's many different versions of VB code that uses MDAC to talk to MSSql. Do you know what the difference is between the two code versions? Is there problems with re-opening connections all the time?



Version 1 of the program is:



Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Public cnxEventLog As New ADODB.Connection (defined globally)
  4.  
  5.  
  6.  
  7. <code in a procedure follows>
  8.  
  9.  
  10. If (cnxEventLog.State <> adStateOpen) Then
  11. 'Set cnxEventLog = New ADODB.Connection
  12. cnxEventLog.Open strConnection
  13. End If
  14.  


Version 2 of the program is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public cnxEventLog As ADODB.Connection (defined globally)
  3.  
  4.  
  5.  
  6. <code in a procedure follows>
  7.  
  8.  
  9. 'If (cnxEventLog.State <> adStateOpen) Then
  10. Set cnxEventLog = New ADODB.Connection
  11. cnxEventLog.Open strConnection
  12. 'End If
  13.  

I appreciate that version 1 checks the connection state before trying to reconnect but it doesn't seem to do all of the connection logic, whereas version 2 always reconnects.



Version 1 is currently running on a machine with VBA. The system runs fine all day calling the connection procedure as shown and then doing an insert, update or query.



Approximately once a day it tries to do 2 database calls (queries, inserts, etc.) and each db call runs the connection procedure first. Once a day, I get the error "ADOB.Command Operation is not allowed on a object referencing a closed or invalid connection". Unfortunately I cannot determine 100% whether that is the only error since my error display logic overwrites with the most recent error, there may or may not be a connection error thrown which is then overwritten with the ADOB.command.



I personally observed this problem and after trying to do inserts, etc. to the database they all failed. I left the system to walk away to get my laptop and when I returned everything worked fine. No changes or actions were taken on the system while I was away.



There are many other times a day (approximately 50) when they do these 2 database calls at the same time and everything works with no problems.



I would really appreciate any help you can provide,



Thanks,



Dave
Apr 26 '07 #1
0 1705

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

Similar topics

1
by: Manuel | last post by:
Hello, I try to export a mssql database into a csv-file. I tried this with asp, but it doesn't work. <% Dim objConn Dim csv_path
7
by: RossM | last post by:
Hey, I am trying to connect to a MSSQL database but i keep getting the error "Compile error: User-defined type not defined". My code is below: Option Explicit Private Sub...
0
by: itamar82 | last post by:
I have a SP running on mssql server 2005. When I try to execute the SP through asp I receive back an error that the parameter @City is not supplied, although I clearly do supply it. Here is my...
2
by: gnomee2 | last post by:
Hello Everyone, I have a strange problem that I cannot seem to solve. I have two server running Windows 2003 MSSQL on one IIS on the other. Out of the blue I have slow queries that cause asp...
2
by: Abadi176 | last post by:
Hello, Can anyone help me how I can create a MSSQL connection trough C# ? I searched a lot but didnt find it. I also have seen the ADODB connection. Should I use the ADODB connection or does...
10
by: khalid galal | last post by:
Hi, i am having a problem with connecting ASP with MSSQL SEVER 2005 EXPRESS EDITION, i am writing ASP code using javascript. look at this peace of code: var myConnect = "Provider=SQLNCLI;Data...
9
by: chromis | last post by:
Hi, I've never coded in ASP before and I'm trying to port a couple of simple PHP files to ASP.NET. The first file addScores.php takes form data and a hash and inserts the data into the db, it...
3
by: Jollywg | last post by:
I keep getting the following error: The expression after update you entered as the event property setting produced the following error: a problem occurred while Microsoft Office Access was...
6
by: avcitamer | last post by:
We upgraded our system and problem below occured, pleas help me... Windows 2003 server SP1 When I set a decimal DB field value to "123,32" (using ADODB.recordset ) updated value was ok (123.32)...
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.