|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Tue May 16, 2006 2:26 pm Post subject: Fortran F95 and SQL Server |
|
|
Can Fortran F95 interact with a database in SQL Server? Can I add, delete or modify a record on a database in SQL Server?
If yes, how can this be done?
Thank you.
Daniel Chan |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Tue May 16, 2006 4:05 pm Post subject: Fortran F95 and SQL Server |
|
|
FTN95 can be used in .NET mode to consume the .NET runtime that has access to database functionality. The ADO .NET classes will provide a good start for what you want to do. I also believe there are other third party products available that you could use with an FTN95 Win32 application to access databases. |
|
Back to top |
|
|
sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Tue May 16, 2006 7:43 pm Post subject: Fortran F95 and SQL Server |
|
|
Canaima's F90SQL is one such - I have used it, although not extensively. It did what I needed it to do, which was the same as what you want. Andy |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Wed May 17, 2006 6:28 am Post subject: Fortran F95 and SQL Server |
|
|
Hi Mr. Smith,
I do not have Visual Studio on my machine. Will ADO .NET requires Visual Studio to work?
Do you have a simple FTN95 program that demonstate how to do a "Select *" from a Table in a database?
Thank you.
Daniel Chan |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Wed May 17, 2006 12:24 pm Post subject: Fortran F95 and SQL Server |
|
|
You can program using .NET using just the SDK (make sure to get the 1.1 SDK not 2.0 just yet). Plato will also let you build .NET assemblies. I am afraid I do not have any sample code for this, but you will need to look into the help system under 'Calling .NET languages from FTN95' and make use of the ADO .NET code to access a database. I would imagine once connected it would be a simple matter of passing a SQL query. |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Fri May 19, 2006 7:52 am Post subject: Fortran F95 and SQL Server |
|
|
Hi Andrew,
I tried to compile .NET example (MessageBox).
I tried the Builddbg.bat and Buildrel.bat. Both failed to run.
The error was on 'library "System.Windows.Forms.dll", The FTN95AUX file did not come with this release of FTN95
But, I found Ftn95Aux.exe at the directory where Salford F95 is put.
What is the correct syntax to compile this file?
Thank you.
Daniel Chan |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
|
Back to top |
|
|
Anonymous Guest
|
Posted: Fri May 19, 2006 9:03 am Post subject: Fortran F95 and SQL Server |
|
|
Hi Andrew,
In your previous message, you explicitly said that I should use .NET 1.1. My machine had it, but has upgraded to .NET 2.0 So, I guess I need to go back to .NET 1.1, right?
Will the builddbg.bat or buildrel.bat work after that?
Thank you.
Daniel Chan |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Fri May 19, 2006 9:48 am Post subject: Fortran F95 and SQL Server |
|
|
Hi,
I found "System.Windows.Forms.dll" in my .NET v2.0 and V1.0 directory. I copy either file to ftn95 directory.
Then, I compile using ftn95 messagebox.f95 /clr /library e:ftn95
The error on "System.Windows.Form.dll" went away.
However, ftn95 still complains about:
"***The FTN95AUX file did not come with this release of FTN95"
Any idea?
Thank you.
Daniel Chan |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
|
Back to top |
|
|
Anonymous Guest
|
Posted: Fri May 19, 2006 1:02 pm Post subject: Fortran F95 and SQL Server |
|
|
Hi Andrew,
I was using FTN95 Ver 4.0
I downloaded and installed FTN95 ver 4.9
I have .NET framework V1.0, V1.1 and V2.0 on the machine. They are in c:windowsmicrosoft.netframeworkvxxxxxx
I went to /demo/net/messagebox to run buildrel.bat
Then, an error came up,
"The procedure entry point GetRequestedRuntimeInfo could not be located in the dynamic link library mscoree.dll."
And then,
"C:WINNTMicrosoft.NETFrameworkV2.0.50727mscorwks.dll could not be loaded"
Any idea?
Thank you.
Daniel Chan
|
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Mon May 22, 2006 4:10 am Post subject: Fortran F95 and SQL Server |
|
|
I think the only problem now is likely to be your PATH setup - could you please confirm you have the 1.1 directory on the path and not 2.0. |
|
Back to top |
|
|
qt
Joined: 23 Aug 2005 Posts: 46 Location: Berlin, Germany
|
Posted: Mon May 29, 2006 2:44 pm Post subject: Fortran F95 and SQL Server |
|
|
Here is an example for a SELECT. The program is based on an ODBC
interface named FORDBC which can be purchased from my company.
However you can create the interface to ODBC yourself or use f90SQL
from Canaima which is very similar.
I just saw that ISS Ltd is offering an ODBC interface too.
This is included in their WINTERACTER v7.1.
Joerg Kuthe
www.qtsoftware.de
Code: | ! FTN95 compile & link:
! ---------------------
! ftn95 T_ODBCAccessRd.f90 /mod_path M:
! Notice: The directory "M:" is the path spec. where modules can be found.
! slink commands:
! lo t_odbcaccessrd
! lo c:windowssystemodbc32.dll
! file
! Notice: ODBC32.dll can be found in the windows system directory, for example "c:windowssystemodbc32.dll"
MODULE EDSR
USE qt_ODBC
! old INTEGER (KIND=RETCODE) :: rtc
! old INTEGER (KIND=HENV) :: env = SQL_NULL_HENV
! old INTEGER (KIND=HDBC) :: dbc = SQL_NULL_HDBC
! old INTEGER (KIND=HSTMT) :: stmt = SQL_NULL_HSTMT
INTEGER (SQLRETURN) :: rtc
INTEGER (SQLHENV) :: env = SQL_NULL_HENV
INTEGER (SQLHDBC) :: dbc = SQL_NULL_HDBC
INTEGER (SQLHSTMT) :: stmt = SQL_NULL_HSTMT
END MODULE EDSR
PROGRAM T_ODBCAccessRd
! reads columns from datasource "ODBCTestAccess"
USE EDSR
USE qt_ODBC_Compiler ! FTN95: in qt_ODBC_FTN.f90; LF90: in qt_ODBC_LF90.f90: MSF Powerst.4.0: in qt_ODBC_MsF.f90
IMPLICIT NONE
INTEGER*2 Id
INTEGER*4 I4
DOUBLE PRECISION DP
CHARACTER (LEN=30) :: Str = ' '
! old INTEGER (KIND=SDWORD) :: LENStr = 30
! old INTEGER (KIND=SDWORD) :: cbStr, cbFixed
INTEGER (SQLINTEGER) :: LENStr = 30
INTEGER (SQLINTEGER) :: cbStr, cbFixedId, cbFixedI4, cbFixedDP
INTEGER, PARAMETER :: I2Missing = -9999
INTEGER, PARAMETER :: I4Missing = -99999999
DOUBLE PRECISION, PARAMETER :: DPMissing = -0.999999999999D99
CHARACTER (LEN=*), PARAMETER :: StrMissing = 'missing value'
INTEGER :: icol ! changing type into I4 helps
! establish environment, connection ...
rtc = SQLAllocEnv( env )
CALL CheckSQLReturnCode (*999)
PRINT*,'Environment Handle =', env
rtc = SQLAllocConnect ( env, dbc )
CALL CheckSQLReturnCode (*998)
PRINT*,'Connection Handle =', dbc
rtc = SQLConnect( dbc, "ODBCTestAccess"//CHAR(0), SQL_NTS, &
CHAR(0), SQL_NTS, CHAR(0), SQL_NTS ) ! note: strings are zero terminated ("//CHAR(0) appended")
CALL CheckSQLReturnCode (*997)
PRINT*,'Connect successful'
! old rtc = SQLSetConnectOption ( dbc, SQL_AUTOCOMMIT, FALSE)
rtc = SQLSetConnectOption ( dbc, SQL_ATTR_AUTOCOMMIT, FALSE)
CALL CheckSQLReturnCode (*997)
PRINT*,'Connect option set'
! set up SQL statement
rtc = SQLAllocStmt (dbc, stmt)
CALL CheckSQLReturnCode (*996)
PRINT*,'Memory for statement allocated'
rtc = SQLExecDirect ( stmt, &
"SELECT id, i4, dp, str FROM Tabelle1"//CHAR(0), SQL_NTSL )
CALL CheckSQLReturnCode (*995)
PRINT*,'SELECT Statement successfully executed'
! bind result columns
icol = 1
rtc = SQLBindColI2 (stmt, icol, SQL_C_SSHORT, Id, 0, cbFixedId )
CALL CheckSQLReturnCode (*995)
icol = 2
rtc = SQLBindColI4 (stmt, icol, SQL_C_SLONG, I4, 0, cbFixedI4 )
CALL CheckSQLReturnCode (*995)
icol = 3
rtc = SQLBindColDP (stmt, icol, SQL_C_DOUBLE, DP, 0, cbFixedDP )
CALL CheckSQLReturnCode (*995)
icol = 4
rtc = SQLBindColChar (stmt, icol, SQL_C_CHAR, Str, LENStr, cbStr )
CALL CheckSQLReturnCode (*995)
PRINT*,'Bind successfull'
PRINT*,'SQL Fetch:'
PRINT*,' Id I4 DP Str cbStr'
! 123456789 1 |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|