DB2Connection connection = new DB2Connection("User ID=db2admin;Password=db2admin;Server=db2;Database=SAMPLE"); connection.Open(); try { DB2Loader loader = new DB2Loader("DEPT", connection); loader.Open(); loader.NextRow(); loader["DEPTNO"] = 111; loader["DNAME"] = DBNull.Value; // database field cannot contain NULL values loader["LOC"] = "NEW YORK"; loader.NextRow(); loader["DEPTNO"] = 1; loader["DNAME"] = DBNull.Value; // database field cannot contain NULL values loader["LOC"] = "CHICAGO"; loader.NextRow(); loader["DEPTNO"] = 2; loader["DNAME"] = DBNull.Value; // database field cannot contain NULL values loader["LOC"] = "DALLAS"; loader.Close(); } catch (DB2Exception ex) { foreach (DB2Error error in ex.Errors) { Console.WriteLine("Message: " + error.Message + Environment.NewLine + "Native: " + error.NativeError.ToString() + Environment.NewLine + "Source: " + error.Source); } }
Dim connection As New DB2Connection("User ID=db2admin;Password=db2admin;Server=db2;Database=SAMPLE") connection.Open() Try Dim loader As New DB2Loader("DEPT", connection) loader.Open() loader.NextRow() loader("DEPTNO") = 111 loader("DNAME") = DBNull.Value ' database field cannot contain NULL values loader("LOC") = "NEW YORK" loader.NextRow() loader("DEPTNO") = 1 loader("DNAME") = DBNull.Value ' database field cannot contain NULL values loader("LOC") = "CHICAGO" loader.NextRow() loader("DEPTNO") = 2 loader("DNAME") = DBNull.Value ' database field cannot contain NULL values loader("LOC") = "DALLAS" loader.Close() Catch ex As DB2Exception For Each [error] As DB2Error In ex.Errors Console.WriteLine((("Message: " + [error].Message _ + Environment.NewLine & "Native: " & [error].NativeError.ToString()) _ + Environment.NewLine & "Source: ") + [error].Source) Next End Try
System.Object
Devart.Data.DB2.DB2Error
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2