Solved

currentproject.connection vs connection string ms access / sql server

Posted on 2014-10-29
6
223 Views
Last Modified: 2015-01-14
I have a function that was written in DAO against ms access mdb backend that i have converted to sql server backend with linked tables.

I have linked tables.  The function uses transactions which i have already determined to not work with DAO and SQL Server based on experience and research.  So i went about converting to ado.

the transactjon setup was
  Dim NewCheck As New adodb.Recordset
 Set TransTemp = DBEngine.Workspaces(0)
    Set CurDb = TransTemp.Databases(0)
   TransTemp.BeginTrans

i am opening the recordset like this:

      NewCheck.Open sqlstmt, CurrentProject.Connection, adUseClient, adLockBatchOptimistic

 NewCheck.AddNew
       NewCheck![Trans Type] = "Check"
       NewCheck![Account Number] = Account
       NewCheck![Check Number] = NextCheckNum
       NewCheck![Check Date] = Me.Check_Date
       NewCheck![Payee] = ChecksToPay![Supplier Name]
       NewCheck![Supplier Number] = ChecksToPay![Supplier Number]
       NewCheck![Payment Amount] = PmtAmt
       NewCheck![Deposit Amount] = 0
       NewCheck![CurrencyCode] = CurCode
       NewCheck![ExchangeRate] = ExChgRate
       NewCheck![Bill Payment] = True
       NewCheck![Posted] = True
       NewCheck![Memo] = "some memo" ' for SQL Contraint
       NewCheck![Posting GL ID] = "0" ' for SQL Contraint
       NewCheck![Voucher] = "some voucher" ' for SQL Contraint.  this is written later in function


...

 NewCheck.Update
       NewCheck.MoveLast ', NewCheck.LastModified


  TransTemp.CommitTrans


It runs without any error, but does not actually write a new record at all.

Do i need a connection string or will currentproject.connection suffice?  Is the DBEngine.Workspaces(0) workspace even the same workspace as my ado connection??

Press
0
Comment
Question by:pressMac
  • 5
6 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40412479
I start with
Dim cnn As ADODB.Connection

Then
Set cnn = CurrentProject.Connection

and finally

NewCheck.Open sqlstmt, CurrentProject.Connection, adUseClient, adLockBatchOptimistic

Have you explicitly Dim'd the connection as ado as you have done with the Recordset?


Kelvin
0
 

Author Comment

by:pressMac
ID: 40413095
This looks like you create the cnn object, but then don't use it when opening the recordset.  

NewCheck.Open sqlstmt, cnn, adUseClient, adLockBatchOptimistic.

So i tried it anyway, and then that make another statement break earlier in the code like so:

   ChecksToPay.Open sqlstmt, CurrentProject.Connection

"Run-TIme error '3251', current provider does not support the necessary interface for Index functionality."
0
 

Author Comment

by:pressMac
ID: 40413098
PS:  the ChecksToPay is dim'd this way:
  Dim ChecksToPay As New ADODB.Recordset
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:pressMac
ID: 40416794
in this function some of the recordsets opened are in SQL Server, and others are in a local tmp .mdb file.  So the currentproject.connection points to the frontend file that is open.  So how to i open directly without odbc, the sql table and the tmp table?
0
 

Accepted Solution

by:
pressMac earned 0 total points
ID: 40541632
There were still some DAO recordsets nested in the transaction.  I removed those and then it worked.
0
 

Author Closing Comment

by:pressMac
ID: 40548528
Other answers to not fix problem.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now