2 // System.Data.Odbc.OdbcError
5 // Brian Ritchie (brianlritchie@hotmail.com)
7 // Copyright (C) Brian Ritchie, 2002
10 using System.Collections;
11 using System.ComponentModel;
13 using System.Data.Common;
15 namespace System.Data.Odbc
\r
17 public class OdbcError
\r
19 string message,source,sqlstate;
\r
24 internal OdbcError(string Source)
\r
28 message="Error in "+source;
\r
32 internal OdbcError(string Source, OdbcHandleType HandleType, IntPtr Handle)
\r
34 short buflen=256,txtlen=0;
\r
35 OdbcReturn ret=OdbcReturn.Success;
\r
36 byte[] buf_MsgText=new byte[buflen];
\r
37 byte[] buf_SqlState=new byte[buflen];
\r
38 bool NeedsDecode=true;
\r
42 case OdbcHandleType.Dbc:
\r
43 ret=libodbc.SQLError(IntPtr.Zero,Handle,IntPtr.Zero, buf_SqlState,
\r
44 ref nativeerror, buf_MsgText, buflen, ref txtlen);
\r
46 case OdbcHandleType.Stmt:
\r
47 ret=libodbc.SQLError(IntPtr.Zero,IntPtr.Zero,Handle, buf_SqlState,
\r
48 ref nativeerror, buf_MsgText, buflen, ref txtlen);
\r
50 case OdbcHandleType.Env:
\r
51 ret=libodbc.SQLError(Handle,IntPtr.Zero,IntPtr.Zero, buf_SqlState,
\r
52 ref nativeerror, buf_MsgText, buflen, ref txtlen);
\r
57 message="Error in "+source;
\r
64 if (ret!=OdbcReturn.Success)
\r
68 message="Unable to retreive error information from ODBC driver manager";
\r
73 sqlstate=System.Text.Encoding.Default.GetString(buf_SqlState).Replace((char) 0,' ').Trim();;
\r
74 message=System.Text.Encoding.Default.GetString(buf_MsgText).Replace((char) 0,' ').Trim();;
\r
79 #endregion // Constructors
83 public string Message
\r
91 public int NativeError
\r
99 public string Source
\r
107 public string SQLState
\r
115 #endregion // Properties