C++Builder 程序员博客
29 Jul
跪求:如何用bcb读取postgresql里的table,并按行显示在bcb里form上的List中去???
不知道没有用过那个数据库!
那个数据库能用ADO连接上么?能连的话,就好办了。
可以看看它是不是提供了访问数据库的API。
List?ListView?
用sqlapi吧,速度快,ccrun 有下载。
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TADOQuery *q;
q->ConnectionString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=stinf.mdb;Persist Security Info=False"; //这里加入你的数据库名称取代 stinf.mdb
String sql="select * form table";
q->SQL->Add(sql);
q->Open() ;
while(!q->Eof )
{
String line;
for(int i=0;i <q->FieldCount ;i++)
line=line+" "+q->Fields->Fields[i]->AsString;
ListBox1->Items->Add(line) ;
}
delete q;
}
postgresql現在有ODBC驅動下載了.
不胜感谢!我试试去啊,回来结贴!