Solved

currentproject.connection vs connection string ms access / sql server

Posted on 2014-10-29
6
219 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
Comment Utility
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
Comment Utility
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
Comment Utility
PS:  the ChecksToPay is dim'd this way:
  Dim ChecksToPay As New ADODB.Recordset
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:pressMac
Comment Utility
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
Comment Utility
There were still some DAO recordsets nested in the transaction.  I removed those and then it worked.
0
 

Author Closing Comment

by:pressMac
Comment Utility
Other answers to not fix problem.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

772 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

9 Experts available now in Live!

Get 1:1 Help Now