3

I am using Npgsql for postgresql in C++/CLI. So, the problem is, I have a db on my computer, and I am trying to select some of data from it's "movies" table. I already entered some data inside it, so I know that it has some data. But when I try to select some of them, answer to my query is empty. My code is like below:

public: string* SelectData(string* torrent)  
        {  
            conn->Open();
            String ^ query = "SELECT title, director, actors, genre FROM movies";
            Npgsql::NpgsqlCommand ^ command = gcnew NpgsqlCommand(query, conn);
            try{
                Npgsql::NpgsqlDataReader ^ dr = command->ExecuteReader();
                for (int i = 0; i < N_TORRENT; i++)
                {
                    if(dr->Read())
                    {
                        string std1 = toStandardString((String^)dr[0]);
                        string std2 = toStandardString((String^)dr[1]);
                        string std3 = toStandardString((String^)dr[2]);
                        string std4 = toStandardString((String^)dr[3]);
                        torrent[i] = std1 + " " + std2 + " " + std3 + " " + std4;
                    }
                } 
                return torrent;
            }  
            finally{  
                conn->Close();  
            }
        }
2
  • Can you provide some log? Commented Mar 31, 2016 at 19:08
  • I only have Output logs from the Visual Studio, and apparently they are not about database. Commented Mar 31, 2016 at 19:19

1 Answer 1

1

(For the ones who will look for this question's answer) Problem solved when I changed my query and look for the "title" column that are not empty. But this is ridiculus, so I beleive the problem was about pgAdmin. Because my insert query was not working either, but I added "rowseffected" variable and it shows the effected row's number and looks like it is working. So the problem is probably about the pgAdmin.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.