locked
Declaration of DbDataReader? RRS feed

  • Question

  • User-859173698 posted

    Dear all,,

    What is the declartion of  DbDataReader?

    thanks in advance,,

    Wednesday, May 7, 2008 6:58 PM

Answers

  • User853727733 posted

     These should do:

    using System.Data; 

    using System.Data.Common;
    using System.Data.SqlClient;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 8, 2008 8:57 AM

All replies

  • User853727733 posted

            DbConnection connection = new SqlConnection();        

            connection.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=d:\tmp\70528cap01\App_Data\PUBS.MDF;Integrated Security=True;User Instance=True"; 

             DbCommand cmd = connection.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "SELECT job_id, job_desc FROM Jobs;";

             connection.Open();
            DbDataReader rdr = cmd.ExecuteReader();

            DataTable publishers = new DataTable();
            publishers.Load(rdr, LoadOption.Upsert);
            connection.Close();

     Is this what you need? Hope I could help...


     

    Wednesday, May 7, 2008 9:46 PM
  • User-859173698 posted

    Thanks alot gbogea ,,

    what I need to import before using DbDataReader?

    Thanks in advance

    Thursday, May 8, 2008 8:22 AM
  • User853727733 posted

     These should do:

    using System.Data; 

    using System.Data.Common;
    using System.Data.SqlClient;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 8, 2008 8:57 AM
  • User-859173698 posted

    Thanks alot gbogea

    I appreciate you,,

    Friday, May 9, 2008 6:39 AM
  • User853727733 posted

    No problem, I'm just glad I could help! 

    Friday, May 9, 2008 9:11 AM