473,769 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ 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.Comma nd 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 1723

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

Similar topics

1
5355
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
13950
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 Text1_Change() Dim cnCon As ADODB.Connection
0
1471
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 code: SP: CREATE PROCEDURE . @Id int output, @Name varchar(100), @Comments text = NULL,
2
2501
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 script timeouts and I cannot figure it out. I have moved some test code to other sites on the server and still have these long delays. I have tried dropping the tables, then the database entirely and restoring and still slow. I run the same code on...
2
1349
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 MSSQL have his own connection like MySql ?
10
4095
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 Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;"; var ConnectObj = Server.CreateObject("ADODB.Connection"); var RS = Server.CreateObject("ADODB.Recordset"); var sql="select * from .dbo.Question"; ...
9
2053
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 returns error or success depending on the success of the query. This is then used by a third party piece of software. My first problem is how to retrieve the result of an insert query to see if the query is successful or not: PHP Version: //...
3
1529
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 communicating with the OLE server or ActiveX control Whats happening is that i have the user click a drop down box (which is populated by a table) then choose the item and it fills in the description and price with the following vba code: (Also this is...
6
4915
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) Windows 2003 server SP2 Now when I set a decimal DB field value to "123,32" (using ADODB.recordset ) updated value is (123.32)
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9996
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.