简体   繁体   English

无法通过MS Access前端在PostgreSQL数据库中创建新行

[英]Unable to create new row in PostgreSQL database through MS Access frontend

I have MS Access application as a frontend and PostgreSQL database as a backend. 我将MS Access应用程序作为前端,将PostgreSQL数据库作为后端。 The problem is that when I want to create new row in database I get 问题是当我想在数据库中创建新行时,

Run-time error '3155': ODBC--insert on a linked table failed 运行时错误'3155':ODBC-在链接表上插入失败

I tried with a simple application. 我尝试了一个简单的应用程序。 Only one table. 只有一张桌子。 The problem is still there. 问题仍然存在。 This is the code: 这是代码:

Dim db As Database
Set db = CurrentDb

Dim rs As Recordset
Set rs = db.OpenRecordset("SELECT * FROM tblTest")

With rs

    .AddNew

.Update

End With

rs.Close
db.Close

It breaks on .Update. 它在.Update上中断。 What could be the reason for such behaviour? 发生这种行为的原因可能是什么? Thanks in advance! 提前致谢!

You probably need to insert some values: 您可能需要插入一些值:

With rs    
    .AddNew
        .Fields("SomeField").Value = something
        .Fields("AnotherField").Value = somethingelse
    .Update
    .Close
End With

Try this for an ODBC connection: 对于ODBC连接,请尝试以下操作:

With rs    
    .AddNew
        .Fields("SomeFieldThatCanBeNull").Value = Null
    .Update
    .Close
End With

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM