Search code examples
winformsc++-cli.net-framework-version

unexpected token(s) proceding";" c++ error C2238


i made a header file for CLR/C++ project and the Player header file explode with errors all of them being the C2238 error

#include<string>
using namespace System::Data::SqlClient;

public ref class Player {
public:
    int ID;
    String^ firstName ;
    String^ lastName;
    int stage;
    int points;
    bool playing;

    //behaviors
    Player()
    {
        //default constractor
        
    }
    Player(System::String^ first,System::String^ last,int stag,int point,bool play)
    {
        firstName = first;
        lastName = last;
        stage = stag;
        points = point;
        playing = play;
    }

    Player^ SaveToSql(Player^ p,SqlCommand^ sqlcomand)
    {
        sqlcomand->Parameters->AddWithValue("@firstName",p->firstName);
        sqlcomand->Parameters->AddWithValue("@lastName", p->lastName);
        sqlcomand->Parameters->AddWithValue("@stage", p->stage);
        sqlcomand->Parameters->AddWithValue("@points",0);
        sqlcomand->Parameters->AddWithValue("@playing",p->playing);
        sqlcomand->ExecuteNonQuery();
        String^ q = "SELECT TOP 1 id FROM playr ORDER BY DESC";
        sqlcomand = gcnew SqlCommand(q);
        p->ID = safe_cast<int>(sqlcomand->ExecuteScalar());
        return p;
    }
};

i don't know man i just wana fix ma code ;)


Solution

  • i just figuired it out, i haven't added namespace System befor Sting^ so basically the answare was add System:: befor every Sting^ in the code