环境winXP,delphi 7, postsgresql 8.4, 已安装odbc for postgresql连接方式ado -> odbc -> postgresql
con1.ConnectionString := 'Provider=MSDASQL.1;Extended Properties="DRIVER={PostgreSQL ODBC Driver(UNICODE)};DATABASE=DataBase1;'
+ ' SERVER=127.0.0.1;PORT=5432;UID=postgres;PWD=123456; '
+ ' ReadOnly=0;Protocol=7.4;FakeOidIndex=0;ShowOidColumn=0; '
+ ' RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=100; '
+ ' Socket=4096;UnknownSizes=0;MaxVarcharSize=254; '
+ ' MaxLongVarcharSize=65536;Debug=0;CommLog=0;Optimizer=1;Ksqo=1; '
+ ' UseDeclareFetch=0;TextAsLongVarchar=1;UnknownsAsLongVarchar=0; '
+ ' BoolsAsChar=1;Parse=0;CancelAsFreeStmt=0; '
+ ' ExtraSysTablePrefixes=dd_;LFConversion=1;UpdatableCursors=1; '
+ ' DisallowPremature=0;TrueIsMinus1=0;BI=0;ByteaAsLongVarBinary=0; '
+ ' UseServerSidePrepare=0"' ;
qry1.Sql.Text := 'select id from table1';
qry1.Active := True;
qry1.Append;
qry1.FieldValues['id'] :='1';//执行到这句报错Field 'id' cannot be modified
con1.ConnectionString := 'Provider=MSDASQL.1;Extended Properties="DRIVER={PostgreSQL ODBC Driver(UNICODE)};DATABASE=DataBase1;'
+ ' SERVER=127.0.0.1;PORT=5432;UID=postgres;PWD=123456; '
+ ' ReadOnly=0;Protocol=7.4;FakeOidIndex=0;ShowOidColumn=0; '
+ ' RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=100; '
+ ' Socket=4096;UnknownSizes=0;MaxVarcharSize=254; '
+ ' MaxLongVarcharSize=65536;Debug=0;CommLog=0;Optimizer=1;Ksqo=1; '
+ ' UseDeclareFetch=0;TextAsLongVarchar=1;UnknownsAsLongVarchar=0; '
+ ' BoolsAsChar=1;Parse=0;CancelAsFreeStmt=0; '
+ ' ExtraSysTablePrefixes=dd_;LFConversion=1;UpdatableCursors=1; '
+ ' DisallowPremature=0;TrueIsMinus1=0;BI=0;ByteaAsLongVarBinary=0; '
+ ' UseServerSidePrepare=0"' ;
qry1.Sql.Text := 'select id from table1';
qry1.Active := True;
qry1.Append;
qry1.FieldValues['id'] :='1';//执行到这句报错Field 'id' cannot be modified
qry1.edit;
qry1.FieldValues['id'] :='1';//执行到这句报错Field 'id' cannot be modified
我知道有zeoslib,今天刚查到的,但如果能不改用,就不要改用别的控件。
“raised exception class EOleException with message '无法插入空行。行必须至少
有一个列值集。'”
qry1.Active := True;
qry1.Append;
qry1.FieldValues['id'] :='1';
qry1.post; //'无法插入空行。行必须至少有一个列值集。'
所有表都不能修改?是不是pgsql的访问限制表里对你这个ip、帐号做了限制?
qry2.ExecSQL;
执行没问题,有数据插入成功