public bool RetrieveValue(string sqlstatement, ref string result) { short value = ODBCDriver.SQLExecDirect(this.m_StatementHandle, sqlstatement, -3); if (!this.IsOK((int)value)) { return(false); } value = ODBCDriver.SQLFetch(this.m_StatementHandle); if (!this.IsOK((int)value)) { ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(false); } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(1024); short num; value = ODBCDriver.SQLGetData(this.m_StatementHandle, 1, 1, stringBuilder, 1024, out num); if (!this.IsOK((int)value)) { ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(false); } result = stringBuilder.ToString(); ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(true); }
private string GetDatabaseName() { short num = 1000; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder((int)num); short fInfoType = 17; short num2 = 0; ODBCDriver.SQLGetInfo(this.m_ConnectionHandle, fInfoType, stringBuilder, num, out num2); return(stringBuilder.ToString()); }
public bool ColumnExist(string tableName, string columnName) { short value = ODBCDriver.SQLColumns(this.m_StatementHandle, null, 0, null, 0, tableName, -3, columnName, -3); if (this.IsOK((int)value)) { value = ODBCDriver.SQLFetch(this.m_StatementHandle); ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(this.IsOK((int)value)); } ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(false); }
private bool TableExist(string tableName) { short value = ODBCDriver.SQLTables(this.m_StatementHandle, null, 0, null, 0, tableName, -3, "TABLE", -3); if (this.IsOK((int)value)) { value = ODBCDriver.SQLFetch(this.m_StatementHandle); ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(this.IsOK((int)value)); } ODBCDriver.SQLCloseCursor(this.m_StatementHandle); return(false); }
private int Connect(string in_connect, ushort driverCompletion, ref string retConnStr) { retConnStr = string.Empty; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(1024); short num = 0; int result = (int)ODBCDriver.SQLDriverConnect(this.m_ConnectionHandle, ODBCDriver.GetActiveWindow(), in_connect, (short)in_connect.Length, stringBuilder, 1024, out num, driverCompletion); retConnStr = stringBuilder.ToString(); short value = ODBCDriver.SQLAllocStmt(this.m_ConnectionHandle, out this.m_StatementHandle); if (!this.IsOK((int)value)) { Log.WriteError("Connection database failed!"); } return(result); }
private bool Initialize() { if (!this.m_IsAllocated) { if (!this.IsOK((int)ODBCDriver.SQLAllocEnv(out this.m_EnvironmentHandle))) { return(false); } if (!this.IsOK((int)ODBCDriver.SQLAllocConnect(this.m_EnvironmentHandle, out this.m_ConnectionHandle))) { return(false); } this.m_IsAllocated = true; } return(true); }
public void Terminate() { if (this.m_IsAllocated) { if (this.m_StatementHandle.ToInt64() != 0L) { ODBCDriver.SQLFreeStmt(this.m_StatementHandle, 0); this.m_StatementHandle = System.IntPtr.Zero; } if (this.m_ConnectionHandle.ToInt64() != 0L) { ODBCDriver.SQLDisconnect(this.m_ConnectionHandle); ODBCDriver.SQLFreeConnect(this.m_ConnectionHandle); this.m_ConnectionHandle = System.IntPtr.Zero; } if (this.m_EnvironmentHandle.ToInt64() != 0L) { ODBCDriver.SQLFreeEnv(this.m_EnvironmentHandle); this.m_EnvironmentHandle = System.IntPtr.Zero; } this.m_IsAllocated = false; } }
private bool CheckConnectionString() { short num = 1000; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder((int)num); short fInfoType = 2; short num2 = 0; ODBCDriver.SQLGetInfo(this.m_ConnectionHandle, fInfoType, stringBuilder, num, out num2); string text = stringBuilder.ToString(); if (!string.IsNullOrEmpty(text)) { this.m_ConnectionString = string.Format("DSN={0};", text); } string databaseName = this.GetDatabaseName(); Log.WriteLine("DatabaseName: " + databaseName); string a; if ((a = databaseName) != null) { //if ((a != "Microsoft SQL Server")) //{ // // *** Coyove Patched *** // // if ((a != "ACCESS")) // if (a != "MariaDB") // { // if ((a != "EXCEL")) // { // Log.WriteError("Return 1"); // return false; // } // DatabaseManager.isExcelExport = true; // this.m_InvalidCharacters = " #".ToCharArray(); // this.m_DataTypeMap.Add(DataType.DOUBLE, "double"); // this.m_DataTypeMap.Add(DataType.TEXT, "TEXT"); // this.m_DataTypeMap.Add(DataType.INTEGER, "int"); // } // else // { DatabaseManager.isExcelExport = false; this.m_InvalidCharacters = ".!`[]".ToCharArray(); this.m_DataTypeMap.Add(DataType.DOUBLE, "DOUBLE PRECISION"); this.m_DataTypeMap.Add(DataType.TEXT, "TEXT"); this.m_DataTypeMap.Add(DataType.INTEGER, "int"); // } //} //else //{ // DatabaseManager.isExcelExport = false; // this.m_InvalidCharacters = "-/ ".ToCharArray(); // this.m_KeywordsMap.Add("Columns", "Columns1"); // this.m_DataTypeMap.Add(DataType.DOUBLE, "float"); // this.m_DataTypeMap.Add(DataType.TEXT, "nvarchar(255)"); // this.m_DataTypeMap.Add(DataType.INTEGER, "int"); //} return(true); } // Log.WriteError("Return 2"); return(false); }
private bool ExecuteSQL(string sqlStmt) { short value = ODBCDriver.SQLExecDirect(this.m_StatementHandle, sqlStmt, sqlStmt.Length); return(this.IsOK((int)value)); }