]>
Commit | Line | Data |
---|---|---|
c92b0f9a | 1 | //---------------------------------------------------------------------------------------- |
d1f47235 DS |
2 | // Name: BrowserDB.h,cpp |
3 | // Purpose: a wxDB class | |
4 | // Author: Mark Johnson | |
b5ffecfc | 5 | // Modified by: |
d1f47235 DS |
6 | // Created: 19991127.mj10777 |
7 | // Copyright: (c) Mark Johnson | |
8 | // Licence: wxWindows license | |
9 | // RCS-ID: $Id$ | |
c92b0f9a | 10 | //---------------------------------------------------------------------------------------- |
8907154c | 11 | |
b5ffecfc GT |
12 | // For compilers that support precompilation, includes "wx/wx.h". |
13 | #include "wx/wxprec.h" | |
c92b0f9a | 14 | //---------------------------------------------------------------------------------------- |
b5ffecfc | 15 | #ifdef __BORLANDC__ |
b5ce269b | 16 | #pragma hdrstop |
b5ffecfc | 17 | #endif |
c92b0f9a | 18 | //---------------------------------------------------------------------------------------- |
b5ffecfc | 19 | #ifndef WX_PRECOMP |
b5ce269b | 20 | #include "wx/wx.h" |
b5ffecfc | 21 | #endif |
c92b0f9a | 22 | //---------------------------------------------------------------------------------------- |
b5ffecfc | 23 | #include "std.h" |
c92b0f9a | 24 | //---------------------------------------------------------------------------------------- |
b5ffecfc | 25 | // Global structure for holding ODBC connection information |
daf06bb8 | 26 | wxDbConnectInf DbConnectInf; |
645889ad | 27 | |
c20a12bd | 28 | #if !wxUSE_ODBC |
5d59e67a GT |
29 | #error Demo cannot be compiled unless setup.h has wxUSE_ODBC set to 1 |
30 | #endif | |
31 | ||
c92b0f9a | 32 | //---------------------------------------------------------------------------------------- |
d1f47235 | 33 | extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ |
645889ad | 34 | |
c92b0f9a | 35 | //---------------------------------------------------------------------------------------- |
daf06bb8 | 36 | wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine) |
b5ffecfc | 37 | { |
645889ad GT |
38 | static wxString msg; |
39 | wxString tStr; | |
40 | if (ErrFile || ErrLine) | |
41 | { | |
daf06bb8 | 42 | msg += _T("File: "); |
645889ad | 43 | msg += ErrFile; |
daf06bb8 JS |
44 | msg += _T(" Line: "); |
45 | tStr.Printf(_T("%d"),ErrLine); | |
645889ad | 46 | msg += tStr.GetData(); |
daf06bb8 | 47 | // msg += _T("\n"); |
645889ad | 48 | } |
daf06bb8 JS |
49 | msg.Append (_T("\nODBC errors:\n")); |
50 | // msg += _T("\n"); | |
645889ad | 51 | /* Scan through each database connection displaying |
3103e8a9 | 52 | * any ODBC errors that have occurred. */ |
645889ad GT |
53 | wxDbList *pDbList; |
54 | for (pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext) | |
55 | { | |
56 | // Skip over any free connections | |
57 | if (pDbList->Free) | |
58 | continue; | |
59 | // Display errors for this connection | |
60 | for (int i = 0; i < DB_MAX_ERROR_HISTORY; i++) | |
61 | { | |
62 | if (pDbList->PtrDb->errorList[i]) | |
63 | { | |
64 | msg.Append(pDbList->PtrDb->errorList[i]); | |
5d2ac6b8 | 65 | if (wxStrcmp(pDbList->PtrDb->errorList[i],wxEmptyString) != 0) |
daf06bb8 | 66 | msg.Append(_T("\n")); |
645889ad GT |
67 | } |
68 | } | |
69 | } | |
daf06bb8 JS |
70 | msg += _T("\n"); |
71 | return (wxChar*) (const wxChar*) msg; | |
b5ffecfc | 72 | } // GetExtendedDBErrorMsg |
13b59a33 | 73 | |
c92b0f9a | 74 | //---------------------------------------------------------------------------------------- |
b5ffecfc GT |
75 | BrowserDB::BrowserDB() |
76 | { | |
eacf9d88 | 77 | PointerToNULL(0); |
5d2ac6b8 WS |
78 | ODBCSource = wxEmptyString; // ODBC data source name (created with ODBC Administrator under Win95/NT) |
79 | UserName = wxEmptyString; // database username - must already exist in the data source | |
80 | Password = wxEmptyString; // password database username | |
645889ad GT |
81 | OnFillSqlTyp(); |
82 | OnFilldbTyp(); | |
b5ffecfc | 83 | } // BrowserDB Constructor |
645889ad | 84 | |
c92b0f9a | 85 | //---------------------------------------------------------------------------------------- |
b5ffecfc GT |
86 | BrowserDB::~BrowserDB() |
87 | { | |
eacf9d88 | 88 | PointerToNULL(1); // Clean up Tables and Databases (Commit, Close and delete) |
b5ffecfc | 89 | } // BrowserDB destructor |
645889ad | 90 | |
c92b0f9a | 91 | //---------------------------------------------------------------------------------------- |
f6bcfd97 | 92 | bool BrowserDB::Initialize(int Quiet) |
b5ffecfc | 93 | { |
645889ad GT |
94 | if (!OnStartDB(Quiet)) |
95 | { | |
96 | wxLogMessage(_("\n\n-E-> BrowserDB::OnStartDB(%s) : Failed ! "),ODBCSource.c_str()); | |
5151c7af | 97 | return false; |
645889ad | 98 | } |
5151c7af | 99 | return true; |
b5ffecfc | 100 | } // BrowserDB:Initialize |
645889ad | 101 | |
c92b0f9a | 102 | //---------------------------------------------------------------------------------------- |
f6bcfd97 | 103 | bool BrowserDB::OnStartDB(int Quiet) |
b5ffecfc | 104 | { |
645889ad GT |
105 | wxStopWatch sw; |
106 | if (!Quiet) | |
107 | wxLogMessage(_("\n-I-> BrowserDB::OnStartDB(%s) : Begin "),ODBCSource.c_str()); | |
108 | if (db_BrowserDB != NULL) | |
109 | { | |
110 | if (!Quiet) | |
eacf9d88 | 111 | wxLogMessage(_("\n-I-> BrowserDB::OnStartDB() : DB is already open.")); |
5151c7af | 112 | return true; |
645889ad | 113 | } |
eacf9d88 GT |
114 | |
115 | DbConnectInf.AllocHenv(); | |
116 | ||
645889ad GT |
117 | //--------------------------------------------------------------------------------------- |
118 | // Connect to datasource | |
119 | //--------------------------------------------------------------------------------------- | |
120 | DlgUser *p_Dlg; | |
5d2ac6b8 | 121 | p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,wxEmptyString); |
d1f47235 DS |
122 | p_Dlg->s_DSN = ODBCSource; |
123 | p_Dlg->s_User = UserName; | |
645889ad GT |
124 | p_Dlg->s_Password = Password; |
125 | p_Dlg->OnInit(); | |
126 | p_Dlg->Fit(); | |
254a2129 | 127 | |
5151c7af | 128 | bool OK = false; |
645889ad GT |
129 | if (p_Dlg->ShowModal() == wxID_OK) |
130 | { | |
131 | (pDoc->p_DSN+i_Which)->Usr = p_Dlg->s_User; | |
132 | (pDoc->p_DSN+i_Which)->Pas = p_Dlg->s_Password; | |
133 | UserName = p_Dlg->s_User; | |
134 | Password = p_Dlg->s_Password; | |
5151c7af | 135 | OK = true; |
645889ad GT |
136 | } |
137 | delete p_Dlg; | |
138 | if (OK) | |
139 | { | |
140 | //-------------------------------------------------------------------------------------- | |
d1f47235 DS |
141 | DbConnectInf.SetDsn(ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT) |
142 | DbConnectInf.SetUserID(UserName); // database username - must already exist in the data source | |
143 | DbConnectInf.SetPassword(Password); // password database username | |
eacf9d88 | 144 | db_BrowserDB = wxDbGetConnection(&DbConnectInf); |
645889ad GT |
145 | // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str()); |
146 | if (db_BrowserDB == NULL) | |
147 | { | |
5d2ac6b8 WS |
148 | DbConnectInf.SetDsn(wxEmptyString); |
149 | DbConnectInf.SetUserID(wxEmptyString); | |
150 | DbConnectInf.SetPassword(wxEmptyString); | |
645889ad GT |
151 | if (!Quiet) |
152 | { | |
153 | wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)")); | |
154 | wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time()); | |
155 | } | |
eacf9d88 | 156 | DbConnectInf.FreeHenv(); |
5151c7af | 157 | return false; |
645889ad GT |
158 | } |
159 | //-------------------------------------------------------------------------------------- | |
160 | if (!Quiet) | |
161 | { | |
162 | Temp1 = db_BrowserDB->GetDatabaseName(); | |
163 | Temp2 = db_BrowserDB->GetDataSource(); | |
164 | wxLogMessage(_("-I-> BrowserDB::OnGetDataSourceODBC() - DatabaseName(%s) ; DataSource(%s)"),Temp1.c_str(),Temp2.c_str()); | |
165 | wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time()); | |
166 | } | |
5151c7af | 167 | return true; |
645889ad GT |
168 | } |
169 | else | |
eacf9d88 GT |
170 | { |
171 | DbConnectInf.FreeHenv(); | |
5151c7af | 172 | return false; |
eacf9d88 | 173 | } |
b5ffecfc | 174 | } |
645889ad | 175 | |
c92b0f9a | 176 | //---------------------------------------------------------------------------------------- |
f6bcfd97 | 177 | bool BrowserDB::OnCloseDB(int Quiet) |
b5ffecfc | 178 | { |
645889ad GT |
179 | if (!Quiet) |
180 | wxLogMessage(_("-I-> BrowserDB::OnCloseDB() : Begin ")); | |
181 | if (db_BrowserDB) | |
182 | { | |
183 | // db_BrowserDB->Close(); | |
184 | wxDbFreeConnection(db_BrowserDB); | |
eacf9d88 GT |
185 | |
186 | DbConnectInf.FreeHenv(); | |
187 | ||
645889ad GT |
188 | db_BrowserDB = NULL; |
189 | } | |
190 | if (!Quiet) | |
191 | wxLogMessage(_("\n-I-> BrowserDB::OnCloseDB() : End ")); | |
5151c7af | 192 | return true; |
b5ffecfc | 193 | } |
645889ad | 194 | |
b5ffecfc | 195 | //---------------------------------------------------------------------------------------- |
74de91cc | 196 | bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) |
b5ffecfc | 197 | { |
645889ad | 198 | SDWORD cb; |
d1f47235 | 199 | int i_dbDataType; |
daf06bb8 | 200 | wxChar s_temp[1024+1]; |
d1f47235 DS |
201 | long l_temp; |
202 | double f_temp; | |
203 | int AnzError=0; | |
645889ad GT |
204 | TIMESTAMP_STRUCT t_temp; |
205 | wxString Temp0; | |
206 | //----------------------------- | |
207 | if (!db_BrowserDB->GetNext()) | |
208 | { | |
74de91cc | 209 | #ifdef __WXDEBUG__ |
645889ad | 210 | Temp0.Printf(_("\n-E-> BrowserDB::OnGetNext - ODBC-Error with GetNext \n-E-> ")); |
daf06bb8 | 211 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad GT |
212 | wxLogMessage(Temp0); |
213 | wxMessageBox(Temp0); | |
74de91cc | 214 | #endif |
5151c7af | 215 | return false; |
645889ad GT |
216 | } |
217 | else | |
218 | { | |
d1f47235 | 219 | int i; |
645889ad GT |
220 | for (i=0;i<Cols;i++) |
221 | { | |
daf06bb8 | 222 | wxStrcpy((cl_BrowserDB+i)->tableName,_T("-E->")); |
412394b8 | 223 | i_dbDataType = (cl_BrowserDB+i)->pColFor->i_dbDataType; |
d1f47235 | 224 | if (i_dbDataType == 0) // Filter unsupported dbDataTypes |
645889ad | 225 | { |
412394b8 | 226 | if (((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_VARCHAR) || |
d1f47235 | 227 | ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_LONGVARCHAR)) |
645889ad | 228 | i_dbDataType = DB_DATA_TYPE_VARCHAR; |
412394b8 | 229 | if ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_C_DATE) |
645889ad | 230 | i_dbDataType = DB_DATA_TYPE_DATE; |
412394b8 | 231 | if ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_C_BIT) |
645889ad | 232 | i_dbDataType = DB_DATA_TYPE_INTEGER; |
412394b8 | 233 | if ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_NUMERIC) |
645889ad | 234 | i_dbDataType = DB_DATA_TYPE_VARCHAR; |
412394b8 | 235 | if ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_REAL) |
645889ad GT |
236 | i_dbDataType = DB_DATA_TYPE_FLOAT; |
237 | } | |
412394b8 | 238 | if ((i_dbDataType == DB_DATA_TYPE_INTEGER) && |
d1f47235 DS |
239 | ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_C_DOUBLE)) |
240 | { // DBASE Numeric | |
645889ad GT |
241 | i_dbDataType = DB_DATA_TYPE_FLOAT; |
242 | } | |
243 | switch(i_dbDataType) | |
244 | { | |
245 | case DB_DATA_TYPE_VARCHAR: | |
5d2ac6b8 | 246 | wxStrcpy(s_temp,wxEmptyString); |
254a2129 | 247 | if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_dbDataType),&s_temp[0],sizeof(s_temp), &cb)) |
645889ad GT |
248 | { |
249 | Temp0.Printf(_("\n-E-> BrowserDB::OnGetNext - ODBC-Error with GetNext of >%s<.\n-E-> "),(cl_BrowserDB+i)->tableName); | |
daf06bb8 | 250 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad GT |
251 | wxLogMessage(Temp0); |
252 | } | |
412394b8 | 253 | Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,s_temp); |
daf06bb8 | 254 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad GT |
255 | break; |
256 | case DB_DATA_TYPE_INTEGER: | |
257 | l_temp = 0; | |
254a2129 | 258 | if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_sqlDataType),&l_temp,sizeof(l_temp), &cb)) |
645889ad GT |
259 | { |
260 | Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); | |
daf06bb8 | 261 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad GT |
262 | } |
263 | else | |
264 | { | |
412394b8 | 265 | Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,l_temp); |
daf06bb8 | 266 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad GT |
267 | } |
268 | break; | |
269 | case DB_DATA_TYPE_FLOAT: | |
270 | f_temp = 0; | |
254a2129 | 271 | if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_sqlDataType),&f_temp,sizeof(f_temp), &cb)) |
645889ad GT |
272 | { |
273 | Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); | |
daf06bb8 | 274 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad GT |
275 | wxMessageBox(Temp0); |
276 | } | |
277 | else | |
278 | { | |
412394b8 | 279 | Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,f_temp); |
daf06bb8 | 280 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad GT |
281 | } |
282 | break; | |
283 | case DB_DATA_TYPE_DATE: | |
254a2129 WS |
284 | t_temp.day = 0; |
285 | t_temp.month = 0; | |
286 | t_temp.year = 0; | |
287 | t_temp.hour = 0; | |
288 | t_temp.minute = 0; | |
289 | t_temp.second = 0; | |
290 | t_temp.fraction = 0; | |
291 | if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_sqlDataType),&t_temp,sizeof(t_temp), &cb)) | |
645889ad GT |
292 | { |
293 | Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); | |
daf06bb8 | 294 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad GT |
295 | } |
296 | else | |
297 | { | |
298 | // i_Nation = 0 = timestamp , 1=EU, 2=UK, 3=International, 4=US | |
d1f47235 DS |
299 | if (((cl_BrowserDB+i)->pColFor->i_Nation == 0) || // TS YYYY-MM-DD |
300 | ((cl_BrowserDB+i)->pColFor->i_Nation == 3)) // IT YYYY-MM-DD | |
645889ad | 301 | { |
412394b8 | 302 | Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,t_temp.year,t_temp.month,t_temp.day, |
645889ad | 303 | t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); |
daf06bb8 | 304 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad | 305 | } |
412394b8 GT |
306 | if (((cl_BrowserDB+i)->pColFor->i_Nation == 1) || // EU DD.MM.YYYY |
307 | ((cl_BrowserDB+i)->pColFor->i_Nation == 2)) // UK DD/MM/YYYY | |
645889ad | 308 | { |
412394b8 | 309 | Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,t_temp.day,t_temp.month,t_temp.year, |
645889ad | 310 | t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); |
daf06bb8 | 311 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad | 312 | } |
d1f47235 | 313 | if ((cl_BrowserDB+i)->pColFor->i_Nation == 3) // US MM/DD/YYYY |
645889ad | 314 | { |
412394b8 | 315 | Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,t_temp.month,t_temp.day,t_temp.year, |
645889ad | 316 | t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); |
daf06bb8 | 317 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad GT |
318 | } |
319 | } | |
320 | break; | |
321 | default: | |
322 | AnzError++; | |
323 | if (AnzError <= 100) | |
324 | { | |
325 | Temp0 = (cl_BrowserDB+i)->colName; | |
412394b8 | 326 | wxLogMessage(_("-E-> BrowserDB::OnGetNext - DB_DATA_TYPE_?? (%d) in Col(%s)"),(cl_BrowserDB+i)->pColFor->i_dbDataType,Temp0.c_str()); |
645889ad GT |
327 | } |
328 | else | |
5151c7af | 329 | return true; |
412394b8 | 330 | Temp0.Printf(_("-E-> unknown Format(%d) - sql(%d)"),(cl_BrowserDB+i)->pColFor->i_dbDataType,(cl_BrowserDB+i)->pColFor->i_sqlDataType); |
daf06bb8 | 331 | wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); |
645889ad GT |
332 | break; |
333 | }; // switch | |
334 | } // for | |
335 | } // else | |
336 | ||
5151c7af | 337 | return true; |
b5ffecfc | 338 | } |
645889ad | 339 | |
b5ffecfc | 340 | //---------------------------------------------------------------------------------------- |
f6bcfd97 | 341 | bool BrowserDB::OnSelect(wxString tb_Name, int Quiet) |
b5ffecfc | 342 | { |
645889ad GT |
343 | wxStopWatch sw; |
344 | wxString SQLStmt; | |
345 | i_Records = 0; | |
346 | //--------------------------------------------------------------------------------------- | |
74de91cc JS |
347 | wxString tablename = db_BrowserDB->SQLTableName(tb_Name.c_str()); |
348 | SQLStmt.sprintf(_T("SELECT * FROM %s"),tablename.c_str()); | |
daf06bb8 | 349 | if (!db_BrowserDB->ExecSql((wxChar *)(SQLStmt.GetData()))) |
645889ad GT |
350 | { |
351 | Temp0.Printf(_("\n-E-> BrowserDB::OnSelect - ODBC-Error with ExecSql of >%s<.\n-E-> "),tb_Name.c_str()); | |
daf06bb8 | 352 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad | 353 | wxLogMessage(Temp0); |
daf06bb8 | 354 | wxMessageBox(_T("-E-> BrowserDB::OnSelect - GetData()")); |
5151c7af | 355 | return false; |
645889ad GT |
356 | } |
357 | //--------------------------------------------------------------------------------------- | |
358 | while (db_BrowserDB->GetNext()) | |
359 | { | |
360 | i_Records++; | |
361 | } | |
362 | //--------------------------------------------------------------------------------------- | |
daf06bb8 | 363 | if (!db_BrowserDB->ExecSql((wxChar *)(SQLStmt.GetData()))) |
645889ad GT |
364 | { |
365 | Temp0.Printf(_("\n-E-> BrowserDB::OnSelect - ODBC-Error with ExecSql of >%s<.\n-E-> "),tb_Name.c_str()); | |
daf06bb8 | 366 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad | 367 | wxLogMessage(Temp0); |
5151c7af | 368 | return false; |
645889ad GT |
369 | } |
370 | //--------------------------------------------------------------------------------------- | |
4e8f1c6d | 371 | // SetColDefs ( 0, "NAME", DB_DATA_TYPE_VARCHAR, Name, SQL_C_WXCHAR, sizeof(Name), true, true); // Primary index |
645889ad GT |
372 | //--------------------------------------------------------------------------------------- |
373 | if (!Quiet) | |
374 | { | |
375 | wxLogMessage(_("\n-I-> BrowserDB::OnSelect(%s) Records(%d): End - Time needed : %ld ms"),tb_Name.c_str(),i_Records,sw.Time()); | |
376 | } | |
5151c7af | 377 | return true; |
b5ffecfc | 378 | } |
645889ad | 379 | |
b5ffecfc | 380 | //---------------------------------------------------------------------------------------- |
f6bcfd97 | 381 | bool BrowserDB::OnExecSql(wxString SQLStmt, int Quiet) |
b5ffecfc | 382 | { |
645889ad | 383 | //--------------------------------------------------------------------------------------- |
daf06bb8 | 384 | if (!db_BrowserDB->ExecSql((wxChar *)(SQLStmt.GetData()))) |
645889ad GT |
385 | { |
386 | Temp0.Printf(_("\n-E-> BrowserDB::OnExecSQL - ODBC-Error with ExecSql of >%s<.\n-E-> "),SQLStmt.c_str()); | |
daf06bb8 | 387 | Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); |
645889ad GT |
388 | if (!Quiet) |
389 | wxLogMessage(Temp0); | |
390 | else | |
daf06bb8 | 391 | wxMessageBox(_T("-E-> BrowserDB::OnExecSql - ExecSql()")); |
5151c7af | 392 | return false; |
645889ad GT |
393 | } |
394 | if (!Quiet) | |
395 | { | |
396 | // wxLogMessage(_("\n-I-> BrowserDB::OnExecSql(%s) - End - Time needed : %ld ms"),SQLStmt.c_str(),sw.Time()); | |
397 | } | |
5151c7af | 398 | return true; |
b5ffecfc | 399 | } |
645889ad | 400 | |
b5ffecfc | 401 | //---------------------------------------------------------------------------------------- |
74de91cc | 402 | wxDbInf* BrowserDB::OnGetCatalog(int WXUNUSED(Quiet)) |
b5ffecfc | 403 | { |
daf06bb8 JS |
404 | wxChar UName[255]; |
405 | wxStrcpy(UName,UserName); | |
645889ad GT |
406 | ct_BrowserDB = db_BrowserDB->GetCatalog(UName); |
407 | return ct_BrowserDB; | |
b5ffecfc | 408 | } |
645889ad | 409 | |
b5ffecfc | 410 | //---------------------------------------------------------------------------------------- |
74de91cc | 411 | wxDbColInf* BrowserDB::OnGetColumns(wxChar *tableName, UWORD numCols, int WXUNUSED(Quiet)) |
b5ffecfc | 412 | { |
daf06bb8 | 413 | wxChar UName[255]; |
645889ad | 414 | int i; |
daf06bb8 | 415 | wxStrcpy(UName,UserName); |
645889ad | 416 | cl_BrowserDB = db_BrowserDB->GetColumns(tableName,&numCols,UName); |
412394b8 | 417 | // cl_BrowserDB->pColFor = new wxDbColFor[numCols]; |
645889ad GT |
418 | for (i=0;i<numCols;i++) |
419 | { | |
412394b8 GT |
420 | // (cl_BrowserDB->pColFor+i)->Format(1,(cl_BrowserDB+i)->dbDataType,(cl_BrowserDB+i)->sqlDataType, |
421 | // (cl_BrowserDB+i)->columnSize, (cl_BrowserDB+i)->decimalDigits); | |
422 | (cl_BrowserDB+i)->pColFor = new wxDbColFor; | |
423 | (cl_BrowserDB+i)->pColFor->Format(1, | |
424 | (cl_BrowserDB+i)->dbDataType, | |
425 | (cl_BrowserDB+i)->sqlDataType, | |
7e961abe | 426 | (cl_BrowserDB+i)->columnLength, |
412394b8 | 427 | (cl_BrowserDB+i)->decimalDigits); |
645889ad GT |
428 | } |
429 | return cl_BrowserDB; | |
b5ffecfc | 430 | } |
645889ad | 431 | |
b5ffecfc | 432 | //---------------------------------------------------------------------------------------- |
eacf9d88 | 433 | void BrowserDB::PointerToNULL(int Art) |
b5ffecfc | 434 | { |
645889ad GT |
435 |