Home > Software design >  Is there any way to connect on AS400 system(iseries) with Visual Studio without using ODBC?
Is there any way to connect on AS400 system(iseries) with Visual Studio without using ODBC?

Time:04-22

I am testing IBM.Data.DB2 and I download las t fix dll from IBM platform. I using this sentences:

myConnectionString = "Server=0.0.0.0:000;DATABASE=LIBRARYAS400;UID=USER;PWD=PASSWORD;Pooling=false;"

        Dim myConn As DB2Connection = New DB2Connection(myConnectionString)
        
        myConn.Open()

When i use this its waits a lot of time i dont know why i dont return anything.

Thats why i am asking about other way connecting to AS400 without using ODBC.

CodePudding user response:

I wrote a library for it. It uses the 6.x version of the iSeries client. It's not well documented and I don't use it anymore but it was heavily used when I wrote it. https://github.com/MikeWills/IBM-i-.NET-Interface. If anything, use it for examples of what worked.

CodePudding user response:

you can use this cool open source JDBCR4 from Scott Klement.

https://www.scottklement.com/jdbc/

This is from the code test in the tool.

     *inlr = *on;

 // Set up CLASSPATH before starting JVM

 p_envval = getenv('CLASSPATH');
 if (p_envval <> *null);
    EnvVal = %str(p_envval);
 endif;
 if %scan('.:':EnvVal) = *zeros;
   eval EnvVal = '.:'   EnvVal;
   eval EnvValChanged = *on;
 endif;
 if %scan('/sqljdbc.jar':EnvVal) = *zeros;
   eval EnvVal = EnvVal   ':/home/DUBMAPJJ01/sqljdbc.jar';
   eval EnvValChanged = *on;
 endif;
 if EnvValChanged;
   putenv('CLASSPATH='   EnvVal);
 endif;

 prop = JDBC_Properties();
 JDBC_setProp(prop: 'userName'     : 'scottklement');
 JDBC_setProp(prop: 'password'     : 'bigboy');
 JDBC_setProp(prop: 'databaseName' : 'ClarifyProd');

 conn = JDBC_ConnProp('com.microsoft.sqlserver.jdbc.SQLServerDriver'
                     :'jdbc:sqlserver://myserver.example.com:1433'
                     : prop );
 JDBC_freeProp(prop);

 if (conn = *NULL);
     return;
 endif;

 // Prepare SQL statement string to select case ID

 prepstm = JDBC_prepStmt(conn:
 'SELECT dbo.table_case.id_number '  
   'FROM  dbo.table_site INNER JOIN '  
   'dbo.table_case ON dbo.table_site.objid = '  
   'dbo.table_case.case_reporter2site INNER JOIN '  
   'dbo.table_x_cat_log ON dbo.table_case.objid = '  
   'dbo.table_x_cat_log.x_cat_log2case INNER JOIN '  
   'dbo.table_contact ON dbo.table_case.case_reporter2contact = '  
   'dbo.table_contact.objid '  
 'WHERE (dbo.table_site.site_id = ?) AND '  
   '(dbo.table_contact.last_name = ?)  AND '  
   '(dbo.table_contact.first_name = ?) AND '  
   '(dbo.table_contact.phone = ?) AND '  
   '(dbo.table_x_cat_log.x_case_title = ?) AND'  
   '(dbo.table_x_cat_log.x_c1 = ?) AND '  
   '(dbo.table_x_cat_log.x_c2 = ?)'   );

 if (prepstm = *NULL);
     jdbc_close(conn);
     return;
 endif;

 // Set SQL parameter values

 JDBC_SetString(prepstm:1:'OH001');
 JDBC_SetString(prepstm:2:'SOX');
 JDBC_SetString(prepstm:3:'PATP');
 JDBC_SetString(prepstm:4:'888-888-2490');
 JDBC_SetString(prepstm:5:
   'Elevated Profile Usage: '  
   'CAHDTK02_DBEDTKRC01_20060929_M456711_RUSH.'  
   'CABALQUINTO@CA');
 JDBC_SetString(prepstm:6:'AS400');
 JDBC_SetString(prepstm:7:'Distrack');

 // Query the database

 rs = jdbc_ExecPrepQry(prepstm);

 dow (jdbc_nextRow(rs));
     CaseID      = jdbc_getCol(rs: 1);
     except;
 enddo;

 JDBC_FreeResult(rs);
 JDBC_FreePrepStmt(prepstm);
 JDBC_Close(conn);

 return;
  • Related