Dynamics AX 3.0 'da ODBC Insert-Update

Son olarak ODBC kullanarak Insert ve Update işlemlerine bakalım, Bu işlemin diğer yaptığımız işlemden çok bir farkı yok.


Static boolean ODBCInsertUpdate()

{
str strSQL;
ODBCConnector ODBCContent; // bir önceki makalede bulunan fonksiyon bulunduğu Class
Statement statementContent;

;
try {

strSQL=strfmt("INSERT INTO Table (fld1,fld2) VALUES ('%1','%2')",statement1,statement2);
statementContent=ODBCConnector::newODBCConnectionStatement();
statementContent.executeUpdate(strSQL);
statementContent.close();
return true;

}
catch (Exception::Error)
{
throw Exception::Error;
}
catch (Exception::Break)
{
throw Exception::Break;
}
catch (Exception::DDEerror)
{
throw Exception::DDEerror;
}
catch (Exception::Deadlock)
{
throw Exception::Error;
}
catch (Exception::Info)
{
throw Exception::Info;
}
catch (Exception::Internal)
{
throw Exception::Internal;
}
catch (Exception::Numeric)
{
throw Exception::Numeric;
}
catch (Exception::Sequence)
{
throw Exception::Sequence;
}
catch (Exception::Warning)
{
throw Exception::Warning;
}
}

Dynamics AX 3.0 'da ODBC Select

Bir önceki makalemizin devamı olarak değerlendirebilirsiniz. Şimdi bir Select ifadesini nasıl kullanacağımızı ve dönen değeri resultSet'e atarak nasıl kullancağımıza bakalım.

Static boolean ODBCSelect()
{
str strSQL;
ODBCConnector ODBCContent; // bir önceki makalede bulunan fonksiyon bulunduğu Class
ResultSet resultSetContent;
Statement statementContent;
int contentID ;
str contentStr;
;
try {

strSQL=strfmt("SELECT * FROM Table WHERE con ='%1' ",statement,);
statementContent=ODBCConnector::newODBCConnectionStatement();
resultSetContent=statementContent.executeQuery(strSQL);
while(resultSetContent.next())
{
contentID = resultSetContent.getInt(1);
contentStr=resultSetContent.getString(2); // Alanın dönen değerdeki yeri parametre olarak verilmeli

}
resultSetContent.close();
statementContent.close();
return true;

}
catch (Exception::Error)
{
throw Exception::Error;
}
catch (Exception::Break)
{
throw Exception::Break;
}
catch (Exception::DDEerror)
{
throw Exception::DDEerror;
}
catch (Exception::Deadlock)
{
throw Exception::Error;
}
catch (Exception::Info)
{
throw Exception::Info;
}
catch (Exception::Internal)
{
throw Exception::Internal;
}
catch (Exception::Numeric)
{
throw Exception::Numeric;
}
catch (Exception::Sequence)
{
throw Exception::Sequence;
}
catch (Exception::Warning)
{
throw Exception::Warning;
}
}

Dynamics AX 3.0 'da ODBC Connection

Bu makalemizde Axapta'da ODBC kullanarak SQL veritabanına nasıl erişeceğimize ait örnekleri görebilirsiniz.
Axaptada ODBC ayarlarını yapmak ve SQL üzerinde işlem yapmak son derece kolaydır.
İlk olarak bir ODBC kullanarak SQL'e nasıl login olacağımıza bakalım. Aşağadaki örnekte görebileceğiniz gibi ODBCConnection ve loginProperty isimli 2sınıf (Classes) kullanılmış. Login olunacak server bilgileri LoginProperty ile tanımlandıktan sonra. Yeni bir ODBCConnection statement 'ı oluştrulur.
diğer örneklerde kullanmak açısından, bu fonksyonun oluşturacağımız ODBCConnector isimli bir classes'da kullanabilirsiniz.

Static Statement newODBCConnectionStatement()
{
ODBCConnection oDBCConnection;
LoginProperty loginProperty;
Statement statement;
;
try
{
loginProperty = new LoginProperty();
loginProperty.setServer("SQLServer");
loginProperty.setDatabase("Database");
loginProperty.setUsername("UserName");
loginProperty.setPassword("UserPassword");

oDBCConnection = new ODBCConnection(loginProperty);
statement = oDBCConnection.createStatement();
Return statement;

}
catch (Exception::Error)
{
throw Exception::Error;
}
catch (Exception::Break)
{
throw Exception::Break;
}
catch (Exception::DDEerror)
{
throw Exception::DDEerror;
}
catch (Exception::Deadlock)
{
throw Exception::Error;
}
catch (Exception::Info)
{
throw Exception::Info;
}
catch (Exception::Internal)
{
throw Exception::Internal;
}
catch (Exception::Numeric)
{
throw Exception::Numeric;
}
catch (Exception::Sequence)
{
throw Exception::Sequence;
}
catch (Exception::Warning)
{
throw Exception::Warning;
}