# How to Read ax2009 Data from VisualStudio2008 through .Net business Connector

**URL:** <https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009>\
**Category:** Technical Forum\
**Created:** [February 19, 2014, 7:10am UTC](https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009 "2014-02-19T07:10:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavanax](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@Pavanax](https://www.dynamicsuser.net/u/Pavanax)\
**Post date:** [February 19, 2014, 7:10am UTC](https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009/1 "2014-02-19T07:10:24Z")

</div>

Hi all,

I am writing a Read method in VS2008 .But it doesn’t read the Ax data and also it display result is nothing…My code is like this…!

any mistake in this…? plz reply Quickly…

public string ReadData()

{

// Create the .NET Business Connector objects.

Axapta ax;

AxaptaRecord axRecord;

string tableName = “EmplTable”;

// The LogisticsAddressState field names for calls to

// the AxRecord.get\_field method.

string strNameField = “EmplId”;

string strStateIdField = “Dimension”;

// The output variables for calls to the

// AxRecord.get\_Field method.

object fieldName, fieldStateId;

try

{

// Login to Microsoft Dynamics AX.

ax = new Axapta();

ax.Logon(null, null, null, null);

// Create a query using the AxaptaRecord class

// for the StateAddress table.

using (axRecord = ax.CreateAxaptaRecord(tableName))

{

// Execute the query on the table.

axRecord.ExecuteStmt(“select \* from %1”);

// Create output with a title and column headings

// for the returned records.

Console.WriteLine(“List of selected records from {0}”, tableName);

Console.WriteLine("{0}\t{1}", strNameField, strStateIdField);

// Loop through the set of retrieved records.

while (axRecord.Found)

{

// Retrieve the record data for the specified fields.

fieldName = axRecord.get\_Field(strNameField);

fieldStateId = axRecord.get\_Field(strStateIdField);

// Display the retrieved data.

Console.WriteLine(fieldName + “\t” + fieldStateId);

// Advance to the next row.

axRecord.Next();

}

// Keep the console window open.

System.Console.WriteLine(“Press any key to exit.”);

System.Console.ReadKey();

}

}

catch (Exception e)

{

Console.WriteLine(“Error encountered: {0}”, e.Message);

// Take other error action as needed.

}

return “Record Reded” ;

}

Regards,

Pavan.

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [February 19, 2014, 8:02am UTC](https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009/2 "2014-02-19T08:02:45Z")

</div>

What exactly happens? Do you get any error? Or does it simply mean that you don’t get any data from AX (maybe because you’re connected to a company without data)?

---

<div class="post-metadata">

**Author:** ![Pavanax](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@Pavanax](https://www.dynamicsuser.net/u/Pavanax)\
**Post date:** [February 19, 2014, 8:40am UTC](https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009/3 "2014-02-19T08:40:46Z")

</div>

No i didn’t get any error…? My problem is, **Read method** not access the Data from **AX 2009**. What I am asking is in my code any mistake is there…? or any additional code required…?

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [February 19, 2014, 8:56am UTC](https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009/4 "2014-02-19T08:56:09Z")

</div>

If you don’t have any EmplTable records in the default company, than your code works as expected and you would waste time if you tried to fix something what works. Unfortunately I don’t know your data - only you can verify it.

Maybe you want to connect to another company or AX instance.

---

<div class="post-metadata">

**Author:** ![Ramank](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@Ramank](https://www.dynamicsuser.net/u/Ramank)\
**Post date:** [February 20, 2014, 10:22am UTC](https://www.dynamicsuser.net/t/how-to-read-ax2009-data-from-visualstudio2008-through-net-business-connector/51009/5 "2014-02-20T10:22:11Z")

</div>

HI Pavan,

plz refer the below link.

[http://community.dynamics.com/ax/f/33/t/112553.aspx](http://community.dynamics.com/ax/f/33/t/112553.aspx)

Raman Kutala.
