Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
Can't cast database type tsvector to String

I'm just getting started with PostgreSQL and am trying to perform a full text search. I've got some records in the table, with a column search of type tsvector. That all works great. However, using Npgsql, I'm trying to execute:

using (var cmd = new NpgsqlCommand())
{
    cmd.CommandText = "SELECT search FROM data";
    cmd.Prepare();
    var reader = cmd.ExecuteReader();
}

But I keep getting an InvalidCastException saying

Can't cast database type tsvector to String

I assume there's something more I need to add for it to correctly convert the types, but documentation for NpgSql seems to be virtually non-existent. Is this just not something that can be done, or should I be doing it differently?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I don't have any knowledge of NpgsqlCommand, but have you tried something like this:

var stringResponse= cmd.ExecuteReader().GetString(0);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!