By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

connect as/400 database from dotnet application: communication error

P: 2
Hi friends
I have tried to connect as/400 database from my window application. as/400 database located in another location. i have tried to connect from my local machine.but its keep on getting error (communication error and connection could not be open). can any one guide me. here i have posted my coding.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using IBM.Data.DB2.iSeries;
  10. using System.IO;
  11. using System.Diagnostics;
  12. namespace dummyas400
  13. {
  14.     //;Database=S068F966
  15.     public partial class Form1 : Form
  16.     {
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void button1_Click(object sender, EventArgs e)
  24.         {
  25.             DataSet ds = new DataSet();
  26.             iDB2Connection con = new iDB2Connection("DataSource=XXX.XX.XXX.XX:XX;userid=XXXXX;password=XXXX;CheckConnectionOnOpen=true;EnablePreFetch=false;");
  27.             con.Open();
  28.             iDB2Command cmd = new iDB2Command();
  29.             iDB2DataAdapter da;
  30.             cmd.Connection = con;
  31.             cmd.CommandText = "select * from marwellsys.sampledb";
  32.  
  33.             //con.Open();
  34.             da = new iDB2DataAdapter(cmd.CommandText, con);
  35.  
  36.             //DataSet ds = new DataSet();
  37.             //ds.Clear();
  38.             da.Fill(ds);
  39.             dataGridView1.DataSource = ds.Tables[0];
  40.             con.Close();
  41.         }
  42.     }
  43. }
Attached Files
File Type: doc Doc1.doc (147.0 KB, 165 views)
Mar 5 '13 #1
Share this Question
Share on Google+
1 Reply


P: 2
I want to create window Application Using Dot Net.In that Application i would like to connect As/400 Database(DB2) as Back End tool. But My DB2 is located in different location. For this Requirement what i do and how its possible. Can any one guide me .
Mar 5 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.