• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

218
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?

about 3 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);
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error