init() public method

public init ( string function, string module, object commDialog ) : void
function string
module string
commDialog object
return void
Example #1
0
        private bool resumeDBAccessMissing(String connectString, bool saveInReport, CSDataBase.cDataBase cn)
        { // TODO: Use of ByRef founded Private Function ResumeDBAccessMissing(ByVal StrConnect As String, ByVal SaveInReport As Boolean, ByRef cn As cDataBase) As Boolean
            try
            {
                // if the database is not access we do nothing
                //
                if (connectString.ToLower().IndexOf("PROVIDER=Microsoft.Jet.OLEDB.4.0;".ToLower()) == 0)
                {
                    return false;
                }

                // get the datasource's name
                //
                String fileName = "";
                fileName = cUtil.getToken(connectString, "Data Source");

                // ask to the user if he wan to search for the database file
                //
                CommonDialog commDialog = null;
                if (FindAccessFile != null)
                {
                    FindAccessFileEventArgs e = new FindAccessFileEventArgs(fileName);
                    FindAccessFile(this, e);
                    if (e.cancel)
                    {
                        return false;
                    }
                    commDialog = e.commonDialog;
                }

                CSKernelFile.cFile file = new CSKernelFile.cFile();

                file.filter = "Access files|*.mdb";
                file.init("ResumeDBAccessMissing", C_MODULE, commDialog);

                if (!file.open(m_pathDefault + Path.DirectorySeparatorChar + file,
                                CSKernelClient.eFileMode.eRead,
                                false,
                                false,
                                eFileAccess.eShared,
                                true,
                                true))
                {
                    return false;
                }

                fileName = file.fullName;

                file.close();

                connectString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName;

                if (!cn.initDb(connectString))
                {
                    return false;
                }

                // save the new location 
                //
                if (saveInReport)
                {
                    m_connect.setStrConnect(connectString);
                }
                return true;

            }
            catch (Exception ex)
            {
                cError.mngError(ex, "ResumeDBAccessMissing", C_MODULE, "");
                return false;
            }
        }