Click here to Skip to main content
15,881,898 members

How link Visual C++ 2012 with PostgreSQL

Sebastian M asked:

Open original thread
Hi Guys!!
I'm beginner in Visual C++, so I want your help.
I wrote simple application, which need database (PostgreSQL). The source code in c++ is ok,
(I hope so :)). In this application is DataViewGird which should connect to database and show me rows and column, but after compilation (without bugs) and running there is grey area without any tables.
I think, problem is in database. Of coruse I have added drivers for SQL to my project and directives in using namespaces. Below, I will show you my code and printscreen from pgAdminIII,where I create my database and there added four colums.


C++
#pragma endregion
		private: NpgsqlConnection^ connection;
		private: NpgsqlCommand^ selectcomm;

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
			 {
 connection = gcnew NpgsqlConnection("server=127.0.0.1; Port=5030; UserId=postgres;  Database=utwory");

                odswiez();
			 }
private: System::Void odswiez()
			 {
		selectcomm = gcnew NpgsqlCommand("select * from plyty", connection);
				 DataSet^ ds = gcnew DataSet("Dane o plytach");
				 NpgsqlDataAdapter^ adapter = gcnew   NpgsqlDataAdapter(selectcomm);
				 adapter ->Fill(ds);
				 bindingSource1->DataSource=ds->Tables[0];
				 dataGridView1->DataSource=bindingSource1;
			 }


I don't know what is wrong...
Do you have any tutorials for this or ideas how create database properly??
Tags: C++/CLI, PostgreSQL

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900