SoFunction
Updated on 2025-03-08

Implementation method of C# connecting to db2 database


string strSql = @"select phone_no from no_store where id<5";
string strConn = "Provider=IBMDADB2;Data Source=Database name;UID=User name;PWD=Password;";
            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                OleDbCommand cmd = new OleDbCommand(strSql, conn);
                try
                {
                    ();
                    OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    (ds);
                    DataTable dt = [0];
                    if (dt != null)
                    {
                        for (int i = 0; i < ; i++)
                        {
("Tel" + i + ":" + [i][0].ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    ();
                }
            }
            ();