Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. cannot convert from 'System::Data::DataSet ^' to 'System::Data::DataSet error

cannot convert from 'System::Data::DataSet ^' to 'System::Data::DataSet error

Scheduled Pinned Locked Moved Managed C++/CLI
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m_mun
    wrote on last edited by
    #1

    Hi, I have developed a small application. But it gives the above error It is declared in another class named "CPassword"

    	SqlConnection ^connect = gcnew SqlConnection();
    	connect->ConnectionString = ConfigurationManager::ConnectionStrings\["SQLConnection"\]->ConnectionString;;
    
    	SqlCommand ^cmd = gcnew SqlCommand();
    	cmd->CommandType = CommandType::StoredProcedure;
    	cmd->CommandText = "GetUserPassword";
    
    	DataSet ^dtSet = gcnew DataSet();
    
    	try
    	{
    		connect->Open();
    		SqlDataAdapter ^adp = gcnew SqlDataAdapter();
    		adp->SelectCommand = cmd;
    
    		cmd->Parameters->Add(gcnew SqlParameter("@user\_id",SqlDbType::VarChar));
    		cmd->Parameters\["@user\_id"\]->Value = userID;
    
    		adp->Fill(dtSet, "Password");
    		return dtSet;
    	}
    

    And I am calling this function from another class

    CPassword ^objPassword = gcnew CPassword();
    DataSet ^dtSet = gcnew DataSet();
    dtSet = objPassword->fn_ReturnPassword(txtUserId->Text);

    Plese help.... Thanks to all

    A 1 Reply Last reply
    0
    • M m_mun

      Hi, I have developed a small application. But it gives the above error It is declared in another class named "CPassword"

      	SqlConnection ^connect = gcnew SqlConnection();
      	connect->ConnectionString = ConfigurationManager::ConnectionStrings\["SQLConnection"\]->ConnectionString;;
      
      	SqlCommand ^cmd = gcnew SqlCommand();
      	cmd->CommandType = CommandType::StoredProcedure;
      	cmd->CommandText = "GetUserPassword";
      
      	DataSet ^dtSet = gcnew DataSet();
      
      	try
      	{
      		connect->Open();
      		SqlDataAdapter ^adp = gcnew SqlDataAdapter();
      		adp->SelectCommand = cmd;
      
      		cmd->Parameters->Add(gcnew SqlParameter("@user\_id",SqlDbType::VarChar));
      		cmd->Parameters\["@user\_id"\]->Value = userID;
      
      		adp->Fill(dtSet, "Password");
      		return dtSet;
      	}
      

      And I am calling this function from another class

      CPassword ^objPassword = gcnew CPassword();
      DataSet ^dtSet = gcnew DataSet();
      dtSet = objPassword->fn_ReturnPassword(txtUserId->Text);

      Plese help.... Thanks to all

      A Offline
      A Offline
      Andreoli Carlo
      wrote on last edited by
      #2

      Can you post the entire CPassword function and the DataSet class...it would help to understand your problem the problem can be in the try catch.....how do you implement the catch (not reported in the forum)

      M 1 Reply Last reply
      0
      • A Andreoli Carlo

        Can you post the entire CPassword function and the DataSet class...it would help to understand your problem the problem can be in the try catch.....how do you implement the catch (not reported in the forum)

        M Offline
        M Offline
        m_mun
        wrote on last edited by
        #3

        Thank u for ur reply. Actually I solved my problem by not returning 'DataSet' object, it pass as a reference in function parameter.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups