csharp ODBC选择e插入
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp ODBC选择e插入相关的知识,希望对你有一定的参考价值。
OdbcConnection connection;
LoginProperty loginProp;
Statement statement;
ResultSet result;
SqlStatementExecutePermission permission;
str sqlSelect;
str sqlStmt1;
str sqlStmt2;
str sqlStmt3;
InventTable inventTable;
utcDateTime fromDate = DateTimeUtil::addDays(DateTimeUtil::utcNow(), -1);
loginProp = new LoginProperty();
loginProp.setOther(SantaClara_Utils::getConnectionStringPrimusTeste());
try
{
connection = new OdbcConnection(loginProp);
}
catch
{
error('You do not have access to the database specified');
return;
}
sqlSelect = @"SELECT Id FROM axi.ProductNumberTable WHERE ProductNumber = %1;";
sqlStmt1 = @"INSERT INTO axi.ProductNumberTable (ProductNumber, Its_Cod) VALUES (%1, %2);";
sqlStmt2 = @"INSERT INTO axi.ItsCodTranslate (ItsCodPiv, ItsCodSec) VALUES (%1, %1);";
sqlStmt3 = @"INSERT INTO axi.ItsCodInventTranslate (ItsCodPiv, ItsCodSec) VALUES (%1, %1);";
permission = new SqlStatementExecutePermission(sqlStmt1);
permission.assert();
statement = connection.createStatement();
while
select inventTable
where inventTable.createdDateTime >= fromDate || inventTable.modifiedDateTime >= fromDate
{
result = statement.executeQuery(strFmt(sqlSelect, inventTable.ItemId));
if (result.next())
{
continue;
}
statement.executeUpdate(strFmt(sqlStmt1, inventTable.ItemId, inventTable.PrimusId));
statement.executeUpdate(strFmt(sqlStmt2, inventTable.PrimusId));
statement.executeUpdate(strFmt(sqlStmt3, inventTable.PrimusId));
}
statement.close();
CodeAccessPermission::revertAssert();
以上是关于csharp ODBC选择e插入的主要内容,如果未能解决你的问题,请参考以下文章
csharp Dapper ODBC QueryMultiple Error
QT ODBC 驱动程序 .mdb ms-access 插入在 1000 行以上时不起作用(Windows)
如果 id 存在则更新,否则插入 (ODBC)
一次查询中的 Odbc 和 Sql 连接
如何使用 Odbc 插入 DateTime 对象?
检索 ODBC 表并插入 SQL Server CE 数据库