web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

SQL Dot net variable Initialization Issue

(0) ShareShare
ReportReport
Posted on by

Hi, We are having requirement to fetch the data from External SQL table and Insert the values in NAV tables.  Once the data has been read then the record should automatically updated as “Completed “  in External table.  This Code unit has to be recurred every 30 minutes using NAS. We have used two dedicated SQL Queries : INSERT, UPDATE.

In NAV we have used DOT NET variables (SQLDATAREADER) to read the data from SQL Table. To update the data I have used SQL DATA ADAPTER concept in dot Net variable (System. Data. Common. DB Data Adapter. 'System. Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089').

( NOTE: We have not used Automation variable (ADO) , since the NAS is performing at backend. )

Issue faced: While running this Query I am Getting error “ Data Adapter not Initialized “ .

Please let me know any solution which is possible as this has become critical for the project.

Thanks

*This post is locked for comments

I have the same question (0)
  • Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    What code did you write using SQL DATA ADAPTER ?

    Can you show us the code?

  • Rashed Profile Picture
    3,765 on at

    Here is an example using datareader.

    mibuso.com/.../using-ado-on-rtc-in-nav

  • Community Member Profile Picture
    on at

    Hi,

    1. First time i tried this  one :

                UpdateSQLStr := 'UPDATE [COPY_MFS].[dbo].[MFDB_LEDGER_PRINCIPAL] SET  [Copied_NAV] = ''1'' , [Copied_Date] = Getdate() ' +

                               'WHERE [COPY_MFS].[dbo].[MFDB_LEDGER_PRINCIPAL].[MFDB_LedgerNumber] = ' + FORMAT(LedgNumber);

                SQLAdapter := SQLAdapter.UpdateCommand(UpdateSQLStr,SQLConnection);

    2. Second time i tried this one :

                 SQLAdapter.UpdateCommand('UPDATE [COPY_MFS].[dbo].[MFDB_LEDGER_PRINCIPAL] SET  [Copied_NAV] = ''1'' , [Copied_Date] = Getdate() ' +

                              'WHERE [COPY_MFS].[dbo].[MFDB_LEDGER_PRINCIPAL].[MFDB_LedgerNumber] = ' + FORMAT(LedgNumber) ) ;

    IN both cases i was getting syntax error

    Thanks

  • Verified answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    You should always CREATE automation/dotnet variables before using them..

    example code is

    IF ISCLEAR(lADOCommand) THEN

    CREATE(lADOCommand);    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans