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