Hi

I am attempting to insert into a remote PostgreSqL database as a novice.

I am using C# 2008 Express, on Windows 7.

I have made a connection through a connection string which works well.

So far I have this code placed after the connection code.

string insertString = @"Insert into p_id.image (logothe_geom, description, text_)"
+ " select st_centroid (graphics.utilities_dgm.the_geom), ('Logo'), ('PDW')"
+ " From graphics.utilities_dgm"
+ " Where graphics.utilities_dgm.utilities_description = 'Base'";

SqlCommand command = new SqlCommand(insertString);
command.ExecuteNonQuery();

This gave me a "Conection property has not been initialized" error.

After a search I attempted to initialize the connection property by adding connectionString to the SQLCommand -
SqlCommand command = new SqlCommand(insertString, connectionString);

But this gives me an error about overloaded method match and invalid arguments.

Any help would be appreciated.

Bob

Assumming you have an open connection called PostgreSqLConnection to the server, you need to pass it as the second parameter, not the connection string.

SqlCommand command = new SqlCommand(insertString, PostgreSqLConnection)

But...
In your insertString you have an insert sentence AND a select, so the command will return data. You are lying if you say that this is a non query.

I would suggest to separate both sentences in 2 separated commands.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.