Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Micros 3700 Res5 OLEDB connection 1

Status
Not open for further replies.

pmegan

Programmer
Aug 29, 2005
1,186
US
Hi,

I'm about to make my first jump into Res5 and need to find out how to connect to the database from a remote pc. I have some .Net applications that connect to my current Res4.x servers using this string:

Code:
Provider=ASAProv.90;EngineName=sql[i]ServerName[/i];UID=custom;PWD=custom;Links=TCPIP(Host=[i]ServerIP[/i]);

Does anybody have the equivalent connection string to a Res5 server now that it uses sybase version 11? Also, the prereq for Res4 installed the Sybase drivers. Is this the same for Res5, and if not do you have any idea there i can get those drivers loaded?

Thanks.
 
I wonder what your thoughts are on how you're going to store the various connection strings. Right now I'm thinking a type-safe enum, but it strikes me that if anyone ever needs to change that (I know that Simphony is running using either Oracle or MS SQL), they would have to have the source code and the ability to recompile it.. I really would prefer that any software I leave behind is maintainable...
 
Hah!

And just so you know I've done about five RES 4 to RES 5 upgrades so far and while I did have to re-validate most of the reports, everything (once you clean up the auto-sequences) seems to run pretty smoothly. Absolutely no problems from the stored procedures yet; though, only one of these sites actually had any custom stored procedures.
 
I'm going through the MSDN right now looking at the OleDb classes and pretty much all of it is the same as the Odbc classes.. which is making me smack my head for not even noticing the DataAdapter class.
 
Hehe.. was trying to test the classes I added to the library and it kept throwing out exceptions that it couldn't connect. Started trying to debug things and check my code against the MSDN, etc etc... finally got up to check the lab computer... someone had shut it down to rebuild the RAID to a new disc... d'oh.

Thanks for the connection string! Working perfectly.
 
I got a little bored and wanted to see how hard it would be to write a little app that would put the syntax highlighting in TekTips format, using the copy-paste from Visual Studios...

Gosh the code to do it got ugly when I started dredging up my regex knowledge >.<

But, the fruits of my labor:

Code:
[COLOR=#0000FF]using[/color][COLOR=#000000] System;
[/color][COLOR=#0000FF]using[/color][COLOR=#000000] System.Data;

[/color][COLOR=#0000FF]namespace[/color][COLOR=#000000] Postec.Micros.Data
{
    [/color][COLOR=#0000FF]public class[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000] : [/color][COLOR=#2B91AF]IDisposable[/color][COLOR=#000000]
    {
        [/color][COLOR=#0000FF]private[/color][COLOR=#000000] [/color][COLOR=#2B91AF]IDbConnection[/color][COLOR=#000000] _IDbConnection;

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Creates a new MicrosDatabase connection using a default OdbcConnection for a backend[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]static[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000] OdbcDbConnection()
        {
            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]new[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000]()
            {
                _IDbConnection = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] System.Data.Odbc.[/color][COLOR=#2B91AF]OdbcConnection[/color][COLOR=#000000]([/color][COLOR=#A31515]"DSN=micros;UID=custom;PWD=custom"[/color][COLOR=#000000])
            };
        }
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Coonstructs a MicrosDatabase object using default DSN of micros using provided Username and Password[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] with an OdbcConnection for a backend[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Username">[/color][COLOR=#008000]Database username to use for connection; using DBA account is NOT recommended[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Password">[/color][COLOR=#008000]Database user's password[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]static[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000] OdbcDbConnection([/color][COLOR=#0000FF]string[/color][COLOR=#000000] Username, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] Password)
        {
            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]new[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000]()
            {
                _IDbConnection = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] System.Data.Odbc.[/color][COLOR=#2B91AF]OdbcConnection[/color][COLOR=#000000]([/color][COLOR=#0000FF]string[/color][COLOR=#000000].Format([/color][COLOR=#A31515]"DSN=micros;UID={0};PWD={1}"[/color][COLOR=#000000], Username, Password))
            };
        }
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Constructions a MicrosDatabase using the provided DSN. Connects using the provided Username and Password.[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Username">[/color][COLOR=#008000]Database username to use for connection; using DBA account is NOT recommended[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Password">[/color][COLOR=#008000]Database user's password[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="DSN">[/color][COLOR=#008000]The DSN configured to connect to micros on the machine. See SysWOW64 folder for connection manager[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]static[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000] OdbcDbConnection([/color][COLOR=#0000FF]string[/color][COLOR=#000000] Username, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] Password, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] DSN)
        {
            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]new[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000]()
            {
                _IDbConnection = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] System.Data.Odbc.[/color][COLOR=#2B91AF]OdbcConnection[/color][COLOR=#000000]([/color][COLOR=#0000FF]string[/color][COLOR=#000000].Format([/color][COLOR=#A31515]"DSN={0};UID={1};PWD={2}"[/color][COLOR=#000000], DSN, Username, Password))
            };
        }
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Creates a new OleDB connection to the micros server.[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Provider">[/color][COLOR=#008000]Specify which version of RES is being run so that the proper connection provider is used[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="ServerName">[/color][COLOR=#008000]The computer name; eg: AT9225[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Username">[/color][COLOR=#008000]The database username to use in our connection; do NOT use DBA as a stored connection[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Password">[/color][COLOR=#008000]The database user's password[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="IPAddress">[/color][COLOR=#008000]The IP address of the server we are connecting to[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]static[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000] OleDbConnection([/color][COLOR=#2B91AF]MicrosOleProvider[/color][COLOR=#000000] Provider, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] ServerName, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] Username, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] Password, [/color][COLOR=#0000FF]string[/color][COLOR=#000000] IPAddress)
        {
            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]new[/color][COLOR=#000000] [/color][COLOR=#2B91AF]MicrosDatabase[/color][COLOR=#000000]()
            {
                _IDbConnection = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] System.Data.OleDb.[/color][COLOR=#2B91AF]OleDbConnection[/color][COLOR=#000000](
                    [/color][COLOR=#0000FF]string[/color][COLOR=#000000].Format([/color][COLOR=#A31515]"Provider={0};EngineName=sql{1};UID={2};PWD={3};Links=TCPIP(Host={4})"[/color][COLOR=#000000],
                        Provider, ServerName, Username, Password, IPAddress))
            };
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Queries the database[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="QueryString">[/color][COLOR=#008000]QueryString to run against the database[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]A data table with the queries result set[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#2B91AF]DataTable[/color][COLOR=#000000] Query([/color][COLOR=#0000FF]string[/color][COLOR=#000000] QueryString)
        {
            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] ([/color][COLOR=#0000FF]string[/color][COLOR=#000000].IsNullOrEmpty(QueryString))
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]null[/color][COLOR=#000000];

            [/color][COLOR=#0000FF]using[/color][COLOR=#000000] ([/color][COLOR=#2B91AF]IDbCommand[/color][COLOR=#000000] Cmd = _IDbConnection.CreateCommand())
            [/color][COLOR=#0000FF]using[/color][COLOR=#000000] ([/color][COLOR=#2B91AF]IDataReader[/color][COLOR=#000000] DbDataReader = Cmd.ExecuteReader())
            {
                Cmd.CommandText = QueryString;

                [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (DbDataReader.FieldCount == 0)
                    [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]null[/color][COLOR=#000000];

                [/color][COLOR=#2B91AF]DataTable[/color][COLOR=#000000] tempTable = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] [/color][COLOR=#2B91AF]DataTable[/color][COLOR=#000000]();
                [/color][COLOR=#2B91AF]DataColumn[/color][COLOR=#000000] tempColumn;
                [/color][COLOR=#0000FF]using[/color][COLOR=#000000] ([/color][COLOR=#2B91AF]DataTable[/color][COLOR=#000000] schemaTable = DbDataReader.GetSchemaTable())
                {
                    [/color][COLOR=#0000FF]for[/color][COLOR=#000000] ([/color][COLOR=#0000FF]int[/color][COLOR=#000000] i = 0; i < schemaTable.Rows.Count; i++)
                    {
                        tempColumn = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] [/color][COLOR=#2B91AF]DataColumn[/color][COLOR=#000000](([/color][COLOR=#0000FF]string[/color][COLOR=#000000])schemaTable.Rows[i][[/color][COLOR=#A31515]"ColumnName"[/color][COLOR=#000000]], ([/color][COLOR=#2B91AF]Type[/color][COLOR=#000000])schemaTable.Rows[i][[/color][COLOR=#A31515]"DataType"[/color][COLOR=#000000]]);
                        [/color][COLOR=#008000]//have to do this because numeric fields can be null in the micros database[/color][COLOR=#000000]
                        tempColumn.AllowDBNull = [/color][COLOR=#0000FF]true[/color][COLOR=#000000];
                        tempTable.Columns.Add(tempColumn);
                    }
                }

                [/color][COLOR=#2B91AF]DataRow[/color][COLOR=#000000] tempRow;
                [/color][COLOR=#0000FF]while[/color][COLOR=#000000] (DbDataReader.Read())
                {
                    tempRow = tempTable.NewRow();
                    [/color][COLOR=#0000FF]for[/color][COLOR=#000000] ([/color][COLOR=#0000FF]int[/color][COLOR=#000000] i = 0; i < DbDataReader.FieldCount; i++)
                        tempRow[i] = DbDataReader[i];
                    tempTable.Rows.Add(tempRow);
                }
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] tempTable;
            }
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Runs a stored procedure on the database that expects a returned data set[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="SPName">[/color][COLOR=#008000]The name of the stored procedure to run. Full name; eg: reports.v_R_sys_menuitem[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="SpParams">[/color][COLOR=#008000]The parametes, if any, to pass to the stored procedure[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The dataset returned by the query[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#2B91AF]DataTable[/color][COLOR=#000000] RunStoredProcedure([/color][COLOR=#0000FF]string[/color][COLOR=#000000] SPName, [/color][COLOR=#2B91AF]SPParam[/color][COLOR=#000000][] SpParams = [/color][COLOR=#0000FF]null[/color][COLOR=#000000])
        {
            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] ([/color][COLOR=#0000FF]string[/color][COLOR=#000000].IsNullOrEmpty(SPName))
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]null[/color][COLOR=#000000];

            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (SpParams == [/color][COLOR=#0000FF]null[/color][COLOR=#000000] || SpParams.Length < 1)
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]this[/color][COLOR=#000000].Query([/color][COLOR=#0000FF]string[/color][COLOR=#000000].Format([/color][COLOR=#A31515]"call {0}"[/color][COLOR=#000000], SPName));

            System.Text.[/color][COLOR=#2B91AF]StringBuilder[/color][COLOR=#000000] sb = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] System.Text.[/color][COLOR=#2B91AF]StringBuilder[/color][COLOR=#000000]();
            sb.Append([/color][COLOR=#A31515]"call "[/color][COLOR=#000000]).Append(SPName).Append([/color][COLOR=#A31515]"("[/color][COLOR=#000000]).Append(SpParams[0].ToString());
            [/color][COLOR=#0000FF]for[/color][COLOR=#000000] ([/color][COLOR=#0000FF]int[/color][COLOR=#000000] i = 1; i < SpParams.Length; i++)
                sb.Append([/color][COLOR=#A31515]","[/color][COLOR=#000000]).Append(SpParams[i].ToString());
            sb.Append([/color][COLOR=#A31515]")"[/color][COLOR=#000000]);

            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]this[/color][COLOR=#000000].Query(sb.ToString());
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Runs a stored procedure on the database with no expected return (eg: micros.sp_PurgeHistory)[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="SPName">[/color][COLOR=#008000]The name of the stored procedure to run. Full name; eg: micros.sp_PurgeHistory[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="SpParams">[/color][COLOR=#008000]The parametes, if any, to pass to the stored procedure[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The number of rows affected[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]int[/color][COLOR=#000000] ExecuteStoredProcedure([/color][COLOR=#0000FF]string[/color][COLOR=#000000] SPName, [/color][COLOR=#2B91AF]SPParam[/color][COLOR=#000000][] SpParams = [/color][COLOR=#0000FF]null[/color][COLOR=#000000])
        {
            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] ([/color][COLOR=#0000FF]string[/color][COLOR=#000000].IsNullOrEmpty(SPName))
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] -1;

            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (SpParams == [/color][COLOR=#0000FF]null[/color][COLOR=#000000] || SpParams.Length < 1)
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]this[/color][COLOR=#000000].Execute([/color][COLOR=#0000FF]string[/color][COLOR=#000000].Format([/color][COLOR=#A31515]"call {0}"[/color][COLOR=#000000], SPName));

            System.Text.[/color][COLOR=#2B91AF]StringBuilder[/color][COLOR=#000000] sb = [/color][COLOR=#0000FF]new[/color][COLOR=#000000] System.Text.[/color][COLOR=#2B91AF]StringBuilder[/color][COLOR=#000000]();
            sb.Append([/color][COLOR=#A31515]"call "[/color][COLOR=#000000]).Append(SPName).Append([/color][COLOR=#A31515]"("[/color][COLOR=#000000]).Append(SpParams[0].ToString());
            [/color][COLOR=#0000FF]for[/color][COLOR=#000000] ([/color][COLOR=#0000FF]int[/color][COLOR=#000000] i = 1; i < SpParams.Length; i++)
                sb.Append([/color][COLOR=#A31515]","[/color][COLOR=#000000]).Append(SpParams[i].ToString());
            sb.Append([/color][COLOR=#A31515]")"[/color][COLOR=#000000]);

            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]this[/color][COLOR=#000000].Execute(sb.ToString());
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Executes an SQL Query against the Micros database.[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="QueryString">[/color][COLOR=#008000]The query to run on the Micros database[/color][COLOR=#808080]</param>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The number of rows affected by the query. -1 for exception/not connected[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]int[/color][COLOR=#000000] Execute([/color][COLOR=#0000FF]string[/color][COLOR=#000000] QueryString)
        {
            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] ([/color][COLOR=#0000FF]string[/color][COLOR=#000000].IsNullOrEmpty(QueryString))
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] 0;

            [/color][COLOR=#0000FF]using[/color][COLOR=#000000] ([/color][COLOR=#2B91AF]IDbCommand[/color][COLOR=#000000] Cmd = _IDbConnection.CreateCommand())
            {
                Cmd.CommandText = QueryString;
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] Cmd.ExecuteNonQuery();
            }
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] If the connection is not already open, this will open the connection[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]If the connection was successful[/color][COLOR=#808080]</returns>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]bool[/color][COLOR=#000000] Connect()
        {
            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (Connected)
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]true[/color][COLOR=#000000];

            _IDbConnection.Open();
            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] Connected;
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Closes the database connection without disposing of the database object[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]bool[/color][COLOR=#000000] Close()
        {
            _IDbConnection.Close();
            [/color][COLOR=#0000FF]return[/color][COLOR=#000000] _IDbConnection.State == [/color][COLOR=#2B91AF]ConnectionState[/color][COLOR=#000000].Closed;
        }


        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Returns current Connected status of Micros database connection[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]bool[/color][COLOR=#000000] Connected
        {
            [/color][COLOR=#0000FF]get[/color][COLOR=#000000]
            {
                [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (_IDbConnection == [/color][COLOR=#0000FF]null[/color][COLOR=#000000])
                    [/color][COLOR=#0000FF]return[/color][COLOR=#000000] [/color][COLOR=#0000FF]false[/color][COLOR=#000000];
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] _IDbConnection.State == System.Data.[/color][COLOR=#2B91AF]ConnectionState[/color][COLOR=#000000].Open;
            }
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Current ConnectionState of the Micros Database Connection[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#2B91AF]ConnectionState[/color][COLOR=#000000] State
        {
            [/color][COLOR=#0000FF]get[/color][COLOR=#000000]
            {
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] _IDbConnection.State;
            }
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Current Micros Database Connection String[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]string[/color][COLOR=#000000] ConnectionString
        {
            [/color][COLOR=#0000FF]get[/color][COLOR=#000000]
            {
                [/color][COLOR=#0000FF]return[/color][COLOR=#000000] _IDbConnection.ConnectionString;
            }
            [/color][COLOR=#0000FF]set[/color][COLOR=#000000]
            {
                _IDbConnection.ConnectionString = [/color][COLOR=#0000FF]value[/color][COLOR=#000000];
            }
        }

        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Calls Dispose(true)[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]public[/color][COLOR=#000000] [/color][COLOR=#0000FF]void[/color][COLOR=#000000] Dispose()
        {
            Dispose([/color][COLOR=#0000FF]true[/color][COLOR=#000000]);
        }
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] Disposes of our database connection[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color][COLOR=#000000]
        [/color][COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Disposing"></param>[/color][COLOR=#000000]
        [/color][COLOR=#0000FF]protected[/color][COLOR=#000000] [/color][COLOR=#0000FF]virtual[/color][COLOR=#000000] [/color][COLOR=#0000FF]void[/color][COLOR=#000000] Dispose([/color][COLOR=#0000FF]bool[/color][COLOR=#000000] Disposing)
        {
            [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (Disposing)
            {
                [/color][COLOR=#0000FF]if[/color][COLOR=#000000] (_IDbConnection != [/color][COLOR=#0000FF]null[/color][COLOR=#000000])
                {
                    _IDbConnection.Dispose();
                    _IDbConnection = [/color][COLOR=#0000FF]null[/color][COLOR=#000000];
                }
            }
        }
    }
}[/color]
 
.. I wouldn't use the code above though given that its untested and there are clearly a few mistakes in there...
 
Moregelen - do you have any docs that list the changes from res 4 to 5? I've got the Res5 RMF and Install guides, but they don't mention the backup moving to a scheduled task. If that's not there, I don't know what else I'm missing.

Thanks
 
I just realized that, while useful, not one of those mentions the task scheduler stuff. We've been using a standard image that we update/upgrade, so after installing it once I never had to look at the docs again. If you'd like, I can keep searching for the official docs, or just send you the information we have about which Group Policies we enforce, and which Tasks we have scheduled.
 
If you stumble across the docs that would be great, but don't go out of your way looking for them. Anything you can send my way is much appreciated.
 
We have three Task Schedule items.

RES Daily Maintenance - Backs up the database and archives the logs
RES Server Reboot - Restarts the Micros server safely; generally chained directly after a weekly Windows Update
RES Client Reboot - Restarts all workstations after server reboot to clear 'No communication' error message before anyone arrives for work


RES Daily Maintenance:
Trigger: 4:35 AM every day
Actions: start a program
Path: D:\MICROS\Res\Pos\Scripts\v5maint.exe
Args: -d: -dlymaint -db

RES Server Reboot (standard image settings):
Trigger: 5:20 AM every Wednesday
Actions: start a program
Path: D:\MICROS\Res\Pos\Scripts\v5maint.exe
Args: -srvreboot

RES Client Reboot (standard image settings):
Trigger: 5:50 AM every Wednesday
Actions: start a program
Path: D:\MICROS\Res\Pos\Scripts\v5maint.exe
Args: -clientreboot


Most current version of v5maint.exe (version 2.0.4.34) published can be downloaded off of my server here (its small, so if the download is slow given its hosted out of my basement, it should be ok):




Now, after all of this, we were running into major issues with Windows Update restarting when it shouldn't. You can't actually set it to automatic AND completely prevent it from restarting auto-magically when it wants to. The best you can do is say 'dont restart with someone logged in', which isn't good enough given that we have a program I wrote on all of our sites that watches user idle time and forces a log off after 15 minutes of idle time. We also don't allow fast user switching or multiple logins at the same time; we did this for two reasons: 1) it was screwing up our remote connect software, 2) If a user uses RDP, this prevents two people from using configurator at the same time and blowing stuff up.

So, we went into Windows Update settings and told it to install updates at 5:00 AM. Then, we enabled the group policy (gpedit.msc) Computer Configuration -> Administrative Templates -> Windows Components -> Windows Update -> Delay Restart for scheduled installations. We set this to its maximum, 30 minutes. So updates install at 5:00 and then delay restart by 30 minutes. At 5:20 AM micros is restarted safely, and we cross our fingers that the updates were done installing.


We have a BUNCH of other policies enabled that do a lot of things like preventing a non admin from shutting down the computer accidentally, completely killing Hibernate, killing the replacement of Shutdown with Install Updates and Shutdown, etc etc.. most of these are our attempts at stupid proofing the system, so you may or may not care for them.
 
I failed to mention, but we also set updates to only install once per week, on Wednesdays.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top