Reading Data through SQL Data Reader in AX 2009

Reading Data through SQL Data Reader in AX 2009

static void CheckDatabaseConThroughDotNet(Args _args)
{
System.Data.SqlClient.SqlConnection con;
System.Data.SqlClient.SqlCommand com;
System.Data.SqlClient.SqlDataAdapter da;
System.Data.SqlClient.SqlDataReader dr;
System.Data.DataSet ds;
str _vendName;
;

try
{
con = new System.Data.SqlClient.SqlConnection(strfmt(“Data Source=Ibrahim; Initial Catalog=DynamicsAx; Integrated Security=true”));
com = new System.Data.SqlClient.SqlCommand(“Select * from VendTable”,con);

con.Open();
dr = com.ExecuteReader();

while(dr.Read())
{
// _vendName = dr(0);

}
con.Close();

}
Catch(Exception::Error)
{
info(“error in Error Class”);
}
Catch(Exception::CLRError)
{
info(CLRInterop::getLastException().ToString());
}
}