Home DotNet The type or namespace name 'DbCommand' could not be found
Author:

While using Enterrpise library I am getting the error "The type or namespace name 'DbCommand' could not be found (are you missing a using directive or an assembly reference?)". 

   19 public class BRCM : System.Web.Services.WebService

   20     {

   21 

   22         [WebMethod]

   23         public string HelloWorld()

   24         {

   25             Database db = DatabaseFactory.CreateDatabase("Test");

   26 

   27             DbCommand cmd = db.GetSqlStringCommand("usp_GetRegion");

   28 

   29             string sRegion = "";

   30 

   31             DataSet ds = db.ExecuteDataSet(cmd);

   32 

   33 

   34             DataSet dsAssignableRoles = new DataSet();

   35             return dsAssignableRoles.GetXml();           

   36         }

   37     }

 The reason you are getting this error is because you are using the DbCommand class and you haven't reference it to the require library. Go to the to of the class file and include the Common library.

using System.Data.Common;

I hope this tutorial has help you :).

 

Happy Programming !!!



Comments (0)
Write comment
Your Contact Details:
Comment:
Security
Please input the anti-spam code that you can read in the image.

"