locked
Reading Data through SQL Data Reader in AX 2009 RRS feed

  • Question

  • Hi,

    I am using the following code in AX 2009 to read the data, fetched from database and want to assign it to a variable but i am not able to do so...

    Please anybody can help me beacuse it will help me to complete my task. 

    I need help on the bold text.

    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());

       }


    }



    • Edited by farrukh635 Wednesday, May 9, 2012 9:56 AM
    Wednesday, May 9, 2012 9:55 AM

Answers

All replies