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

  • Verified answer
    Mohana Yadav Profile Picture
    60,232 Super User 2025 Season 1 on at
    RE: SQL Dot net variable Initialization Issue

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

    example code is

    IF ISCLEAR(lADOCommand) THEN

    CREATE(lADOCommand);    

  • Community Member Profile Picture
    on at
    RE: SQL Dot net variable Initialization Issue

    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

  • Rashed Profile Picture
    3,765 on at
    RE: SQL Dot net variable Initialization Issue

    Here is an example using datareader.

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

  • Mohana Yadav Profile Picture
    60,232 Super User 2025 Season 1 on at
    RE: SQL Dot net variable Initialization Issue

    What code did you write using SQL DATA ADAPTER ?

    Can you show us the code?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans