websss
asked on
c# insert into postgres using Npgsql - 42P01: relation does not exist
Hi
I'm using npgsql for first time with postgres 11 db
My code is as follows
However, I get the error
i've tried the following
Nothing seems to work, the same error exists
When I browse my DB in Navicat, the table is under the public schema and I can connect fine
What am i doing wrong?
I'm using npgsql for first time with postgres 11 db
My code is as follows
cmd = new NpgsqlCommand("INSERT INTO \"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data) " +
"VALUES(@ImeiNumber, @GPSDateTime, @EventId, @Speed, @Latitude, @Longitude, @Heading, @RawData);", con, transactSql)
{
CommandType = CommandType.Text
};
cmd.Parameters.AddWithValue("@ImeiNumber", item.ImeiNumber);
cmd.Parameters.AddWithValue("@GPSDateTime", item.GPSDateTime);
cmd.Parameters.AddWithValue("@EventId", item.EventId);
cmd.Parameters.AddWithValue("@Speed", item.Speed);
cmd.Parameters.AddWithValue("@Latitude", item.Latitude);
cmd.Parameters.AddWithValue("@Longitude", item.Longitude);
cmd.Parameters.AddWithValue("@Heading", item.Heading);
cmd.Parameters.AddWithValue("@RawData", item.RawData);
cmd.ExecuteNonQuery();
However, I get the error
{"42P01: relation \"tracking_dataa\" does not exist"}
i've tried the following
INSERT INTO \"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data
INSERT INTO tracking_dataa (imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data
INSERT INTO \"public\".\"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data
INSERT INTO public.tracking_dataa (imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data
Nothing seems to work, the same error exists
When I browse my DB in Navicat, the table is under the public schema and I can connect fine
What am i doing wrong?
ASKER
Thanks
I can see the table and I copied the settings from navicat into my config file (i only have 1 server)
How would I apply a migration?
I can see the table and I copied the settings from navicat into my config file (i only have 1 server)
How would I apply a migration?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi webss,
This error indicates that you have not applied migration to the database. Please apply migration.
The table might be there but it could be very well an older table.
Additionally, check if you are connecting the to the right database.
Regards,
Chinmay.