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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Micros ODBC Connection

Status
Not open for further replies.
Mar 17, 2010
78
US
Hi,

I have a non micros PC that I would like to run some vb.net code on that connects to a micros server on the same network via ODBC. I have my code running fine on a micros machine connecting to another micros machine but i cant seem to get the odbc connection straight on the computer not running micros.

The micros server I am trying to connect to is running RES 5.1 on a Windows 7 32 bit platform.

The computer I am trying to connect with is a Windows 7 64 bit machine.

I have installed the SA1201_Client.exe on the non-micros machine and setup an odbc that indicates it connects but the connection string I am using in the vb.net code will not connect.

Conneciton string =
DataConn.ConnectionString = "DSN=Micros;EngineName=*******;UID=*****;PWD=******;Links=TCPIP(Host=***.***.***.***)"

What do I need to register to get the sqlanywhere 11 odbc option on the 64 bit windows machine?

Any assistance would be greatly appreciated.
 
Micros only provides the 32 bit version of the Sybase software.
Copy the entire SQL drivers to your client computer. (C:\Program Files(x86)\SQL Anywhere 11\)
Register them using C:\Windows\SysWOW64\regsvr32.exe
Compile your .Net project as a 32 bit application.

I've had absolutely no luck whatsoever connecting to a Micros server remotely using ODBC, so I use OleDB Connection objects with this template for the connection string as an application setting (I name it Sybase11):

Provider=SAOLEDB.11;EngineName=sql{0};UID={1};PWD={2};Links=TCPIP(Host={3});

So if you're connection to a server named MICROS37 with IP 2.2.2.2 and database credential support/support, the connection would look like this:

Code:
[indent]
Dim strConn As String = [String].Format(My.Settings.Sybase11, "MICROS37", "support", "support", "2.2.2.2")
Dim dbConn As New OleDb.OleDbConnection(strConn)

Try
[indent]dbConn.Open()

' do your stuff here

dbConn.Close()[/indent]

Catch ex As OleDb.OleDbException
[indent]MessageBox.Show("OleDB Exception" & vbCrLf & ex.Message)[/indent]

Catch ex As SqlClient.SqlException
[indent]MessageBox.Show("OleDB Exception" & vbCrLf & ex.Message)[/indent]

Catch ex As Exception
[indent]MessageBox.Show("OleDB Exception" & vbCrLf & ex.Message)[/indent]

Finally
[indent]If dbConn.State = ConnectionState.Open Then
[indent]dbConn.Close()[/indent]
End If[/indent]

End Try

[/indent]
 
Hey Pmegan, thanks for your response, I knew someone had to have had a simlar issue.

Can you please give me some details on SAOLEDB.11

What needs to be installed and where did you obtain the installation package? Any further asisstance would be appreciated.
 
Ok, a few more questions to get through this if I may:

Per your instructions above -

Copy the entire SQL drivers to your client computer. (C:\Program Files(x86)\SQL Anywhere 11\) - I have browsed to C:\Program Files (x86)\SQL Anywhere 11 on my source code machine. What specifically in this directory would be the SQL drivers? It lloks like all the .dll's are in the Bin32 folder. Is that what I need to copy to my 64 bit client machine?

Register them using C:\Windows\SysWOW64\regsvr32.exe - Is there a batch way to register all the .dll's at once?

So sorry to have so many questions, I do appreciate any help you can provide.

 
Sorry, that wasn't really clear. The path I gave is on the Micros server. I just copy the whole thing to the same location on my dev pc.

The file you have to register is dboledb11.dll. The ODBC driver is in there too, dbodbc11.dll if you're feeling adventurous. I don't know if it has any dependencies, so usually just copy the whole folder. There's definitely stuff in there that you can do away with though.
 
Hey pmegan,

I am not sure if I explained my scenario correctly. I have a dev environment on a 32 bit Win 7 machine with Micros installed. The application I have written is interfacing with a Micros Lab machine that is also Win 7 32 bit. Everything is happy in this config.

The problem I am running into is when I try to run my application on a seperate Win 7 64 bit machine that i am calling a client machine.

I have copied over the .dlls from my 32bit win 7 machine to the 64 bit win 7 machine and registered them per your recommendation.

Now I am thinking I just need to rewrite my code to use an OLEdb connection instead of ODBC and it should work on the 64 bit client. Does that sound right?

Thanks again for all your help.
 
Close.
You have to switch over to the OleDB connection. If you dragged ODBC objects to your form you can probably just delete them, drag in the OleDB objects and give them the same name. If you coded them in you can just change the data type in the declarations. All of the data objects use the IDb interfaces, (IDbConnection, IDbCommand, etc...), so the properties and methods for OleDB and ODBC objects will be pretty much the same.

The other thing is to force it to be a 32 bit application instead of the default "any cpu" that's used by default. If you leave the default it will run as 64 bit on your client machine and won't be able to find the 32 bit DB drivers. To do this right click the application name in project explorer and select Properties. On the Left side, go to Compile, change the Target CPU to x86 and rebuild, (this is for VB 2013, but should be similar if you're using something else). If you're referencing any other dll's they'll have to be compiled as 32 bit as well.
 
If your software is being written to run on the Micros server itself, you should probably stick to an ODBC connection that way you don't have to worry about configuring IP addresses. All your user would have to do then is (assuming they have one of the standard third party SQL accounts)... run the program.
 
Here is some example code I posted a while ago for a library I've been using, C# rather than VB.

Code:
[COLOR=#0000FF]using[/color] System;
[COLOR=#0000FF]using[/color] System.Data;
 
[COLOR=#0000FF]namespace[/color] Postec.Micros.Data
{
    [COLOR=#0000FF]public[/color] [COLOR=#0000FF]class[/color] [COLOR=#2B91AF]MicrosDatabase[/color] : [COLOR=#2B91AF]IDisposable[/color]
    {
        [COLOR=#0000FF]private[/color] [COLOR=#2B91AF]IDbConnection[/color] _IDbConnection;
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Creates a new MicrosDatabase connection using a default OdbcConnection for a backend[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]static[/color] [COLOR=#2B91AF]MicrosDatabase[/color] OdbcDbConnection()
        {
            [COLOR=#0000FF]return[/color] [COLOR=#2B91AF]MicrosDatabase[/color].OdbcDbConnection([COLOR=#A31515]"custom"[/color], [COLOR=#A31515]"custom"[/color], [COLOR=#A31515]"micros"[/color]);
        }
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Coonstructs a MicrosDatabase object using default DSN of micros using provided Username and Password[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] with an OdbcConnection for a backend[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Password">[/color][COLOR=#008000]Database user's password[/color][COLOR=#808080]</param>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]static[/color] [COLOR=#2B91AF]MicrosDatabase[/color] OdbcDbConnection([COLOR=#0000FF]string[/color] Username, [COLOR=#0000FF]string[/color] Password)
        {
            [COLOR=#0000FF]return[/color] [COLOR=#2B91AF]MicrosDatabase[/color].OdbcDbConnection(Username, Password, [COLOR=#A31515]"micros"[/color]);
        }
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Constructions a MicrosDatabase using the provided DSN. Connects using the provided Username and Password.[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Password">[/color][COLOR=#008000]Database user's password[/color][COLOR=#808080]</param>[/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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]static[/color] [COLOR=#2B91AF]MicrosDatabase[/color] OdbcDbConnection([COLOR=#0000FF]string[/color] Username, [COLOR=#0000FF]string[/color] Password, [COLOR=#0000FF]string[/color] DSN)
        {
            [COLOR=#0000FF]return[/color] [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]MicrosDatabase[/color]()
            {
                _IDbConnection = [COLOR=#0000FF]new[/color] System.Data.Odbc.[COLOR=#2B91AF]OdbcConnection[/color]([COLOR=#0000FF]string[/color].Format([COLOR=#A31515]"DSN={0};UID={1};PWD={2}"[/color], DSN, Username, Password))
            };
        }
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Creates a new OleDB connection to the micros server.[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="ServerName">[/color][COLOR=#008000]The computer name; eg: AT9225[/color][COLOR=#808080]</param>[/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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Password">[/color][COLOR=#008000]The database user's password[/color][COLOR=#808080]</param>[/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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The new MicrosDatabase[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]static[/color] [COLOR=#2B91AF]MicrosDatabase[/color] OleDbConnection([COLOR=#2B91AF]MicrosOleProvider[/color] Provider, [COLOR=#0000FF]string[/color] ServerName, [COLOR=#0000FF]string[/color] Username, [COLOR=#0000FF]string[/color] Password, [COLOR=#0000FF]string[/color] IPAddress)
        {
            [COLOR=#0000FF]return[/color] [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]MicrosDatabase[/color]()
            {
                _IDbConnection = [COLOR=#0000FF]new[/color] System.Data.OleDb.[COLOR=#2B91AF]OleDbConnection[/color](
                    [COLOR=#0000FF]string[/color].Format([COLOR=#A31515]"Provider={0};EngineName=sql{1};UID={2};PWD={3};Links=TCPIP(Host={4})"[/color],
                        Provider, ServerName, Username, Password, IPAddress))
            };
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Queries the database[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#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=#0000FF]public[/color] [COLOR=#2B91AF]DataTable[/color] Query([COLOR=#0000FF]string[/color] QueryString)
        {
            TriggerQuery(QueryString);
            [COLOR=#0000FF]if[/color] ([COLOR=#0000FF]string[/color].IsNullOrEmpty(QueryString))
                [COLOR=#0000FF]return[/color] [COLOR=#0000FF]null[/color];
 
            [COLOR=#0000FF]using[/color] ([COLOR=#2B91AF]IDbCommand[/color] Cmd = _IDbConnection.CreateCommand())
            {
                Cmd.CommandText = QueryString;
                [COLOR=#0000FF]using[/color] ([COLOR=#2B91AF]IDataReader[/color] DbDataReader = Cmd.ExecuteReader())
                {
                    [COLOR=#0000FF]if[/color] (DbDataReader.FieldCount == 0)
                        [COLOR=#0000FF]return[/color] [COLOR=#0000FF]null[/color];
 
                    [COLOR=#2B91AF]DataTable[/color] tempTable = [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]DataTable[/color]();
                    [COLOR=#2B91AF]DataColumn[/color] tempColumn;
                    [COLOR=#0000FF]using[/color] ([COLOR=#2B91AF]DataTable[/color] schemaTable = DbDataReader.GetSchemaTable())
                    {
                        [COLOR=#0000FF]for[/color] ([COLOR=#0000FF]int[/color] i = 0; i < schemaTable.Rows.Count; i++)
                        {
                            tempColumn = [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]DataColumn[/color](([COLOR=#0000FF]string[/color])schemaTable.Rows[i][[COLOR=#A31515]"ColumnName"[/color]], ([COLOR=#2B91AF]Type[/color])schemaTable.Rows[i][[COLOR=#A31515]"DataType"[/color]]);
                            [COLOR=#008000]//have to do this because numeric fields can be null in the micros database[/color]
                            tempColumn.AllowDBNull = [COLOR=#0000FF]true[/color];
                            tempTable.Columns.Add(tempColumn);
                        }
                    }
 
                    [COLOR=#2B91AF]DataRow[/color] tempRow;
                    [COLOR=#0000FF]while[/color] (DbDataReader.Read())
                    {
                        tempRow = tempTable.NewRow();
                        [COLOR=#0000FF]for[/color] ([COLOR=#0000FF]int[/color] i = 0; i < DbDataReader.FieldCount; i++)
                            tempRow[i] = DbDataReader[i];
                        tempTable.Rows.Add(tempRow);
                    }
                    [COLOR=#0000FF]return[/color] tempTable;
                }
            }
        }
 
        [COLOR=#0000FF]public[/color] [COLOR=#2B91AF]IDataReader[/color] RawQuery([COLOR=#0000FF]string[/color] QueryString)
        {
            TriggerQuery(QueryString);
            [COLOR=#0000FF]if[/color] ([COLOR=#0000FF]string[/color].IsNullOrEmpty(QueryString))
                [COLOR=#0000FF]return[/color] [COLOR=#0000FF]null[/color];
 
            [COLOR=#0000FF]using[/color] ([COLOR=#2B91AF]IDbCommand[/color] Cmd = _IDbConnection.CreateCommand())
            {
                Cmd.CommandText = QueryString;
                [COLOR=#0000FF]return[/color] Cmd.ExecuteReader();
            }
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Runs a stored procedure on the database that expects a returned data set[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The dataset returned by the query[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#2B91AF]DataTable[/color] RunStoredProcedure([COLOR=#0000FF]string[/color] SPName, [COLOR=#2B91AF]SPParam[/color][] SpParams = [COLOR=#0000FF]null[/color])
        {
            [COLOR=#0000FF]return[/color] [COLOR=#0000FF]this[/color].Query(FormatStoredPorcedure(SPName, SpParams));
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Runs a stored procedure on the database that expects a returned data set[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The dataset returned by the query[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#2B91AF]IDataReader[/color] RawRunStoredProcedure([COLOR=#0000FF]string[/color] SPName, [COLOR=#2B91AF]SPParam[/color][] SpParams = [COLOR=#0000FF]null[/color])
        {
            [COLOR=#0000FF]return[/color] [COLOR=#0000FF]this[/color].RawQuery(FormatStoredPorcedure(SPName, SpParams));
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Runs a stored procedure on the database with no expected return (eg: micros.sp_PurgeHistory)[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#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=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]The number of rows affected[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]int[/color] ExecuteStoredProcedure([COLOR=#0000FF]string[/color] SPName, [COLOR=#2B91AF]SPParam[/color][] SpParams = [COLOR=#0000FF]null[/color])
        {
            [COLOR=#0000FF]return[/color] [COLOR=#0000FF]this[/color].Execute(FormatStoredPorcedure(SPName, SpParams));
        }
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Internal method to format a stored procedure into a usable SQL query string[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="SPName"></param>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="SpParams"></param>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns></returns>[/color]
        [COLOR=#0000FF]private[/color] [COLOR=#0000FF]string[/color] FormatStoredPorcedure([COLOR=#0000FF]string[/color] SPName, [COLOR=#2B91AF]SPParam[/color][] SpParams = [COLOR=#0000FF]null[/color])
        {
            [COLOR=#0000FF]if[/color] ([COLOR=#0000FF]string[/color].IsNullOrEmpty(SPName))
                [COLOR=#0000FF]return[/color] [COLOR=#0000FF]null[/color];
 
            [COLOR=#0000FF]if[/color] (SpParams == [COLOR=#0000FF]null[/color] || SpParams.Length < 1)
                [COLOR=#0000FF]return[/color] [COLOR=#0000FF]string[/color].Format([COLOR=#A31515]"call {0}"[/color], SPName);
 
            System.Text.[COLOR=#2B91AF]StringBuilder[/color] sb = [COLOR=#0000FF]new[/color] System.Text.[COLOR=#2B91AF]StringBuilder[/color]();
            sb.Append([COLOR=#A31515]"call "[/color]).Append(SPName).Append([COLOR=#A31515]"("[/color]).Append(SpParams[0].ToString());
            [COLOR=#0000FF]for[/color] ([COLOR=#0000FF]int[/color] i = 1; i < SpParams.Length; i++)
                sb.Append([COLOR=#A31515]","[/color]).Append(SpParams[i].ToString());
            sb.Append([COLOR=#A31515]")"[/color]);
 
            [COLOR=#0000FF]return[/color] sb.ToString();
        }
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Executes an SQL Query against the Micros database.[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/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=#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=#0000FF]public[/color] [COLOR=#0000FF]int[/color] Execute([COLOR=#0000FF]string[/color] QueryString)
        {
            TriggerQuery(QueryString);
            [COLOR=#0000FF]if[/color] ([COLOR=#0000FF]string[/color].IsNullOrEmpty(QueryString))
                [COLOR=#0000FF]return[/color] 0;
 
            [COLOR=#0000FF]using[/color] ([COLOR=#2B91AF]IDbCommand[/color] Cmd = _IDbConnection.CreateCommand())
            {
                Cmd.CommandText = QueryString;
                [COLOR=#0000FF]return[/color] Cmd.ExecuteNonQuery();
            }
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] If the connection is not already open, this will open the connection[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns>[/color][COLOR=#008000]If the connection was successful[/color][COLOR=#808080]</returns>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]bool[/color] Connect()
        {
            [COLOR=#0000FF]if[/color] (Connected)
                [COLOR=#0000FF]return[/color] [COLOR=#0000FF]true[/color];
 
            _IDbConnection.Open();
            [COLOR=#0000FF]return[/color] Connected;
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Closes the database connection without disposing of the database object[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]bool[/color] Close()
        {
            _IDbConnection.Close();
            [COLOR=#0000FF]return[/color] _IDbConnection.State == [COLOR=#2B91AF]ConnectionState[/color].Closed;
        }
 
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Returns current Connected status of Micros database connection[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]bool[/color] Connected
        {
            [COLOR=#0000FF]get[/color]
            {
                [COLOR=#0000FF]if[/color] (_IDbConnection == [COLOR=#0000FF]null[/color])
                    [COLOR=#0000FF]return[/color] [COLOR=#0000FF]false[/color];
                [COLOR=#0000FF]return[/color] _IDbConnection.State == System.Data.[COLOR=#2B91AF]ConnectionState[/color].Open;
            }
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Current ConnectionState of the Micros Database Connection[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#2B91AF]ConnectionState[/color] State
        {
            [COLOR=#0000FF]get[/color]
            {
                [COLOR=#0000FF]return[/color] _IDbConnection.State;
            }
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Current Micros Database Connection String[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]string[/color] ConnectionString
        {
            [COLOR=#0000FF]get[/color]
            {
                [COLOR=#0000FF]return[/color] _IDbConnection.ConnectionString;
            }
            [COLOR=#0000FF]set[/color]
            {
                _IDbConnection.ConnectionString = [COLOR=#0000FF]value[/color];
            }
        }
 
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Calls Dispose(true)[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]void[/color] Dispose()
        {
            Dispose([COLOR=#0000FF]true[/color]);
        }
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] Disposes of our database connection[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
        [COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="Disposing"></param>[/color]
        [COLOR=#0000FF]protected[/color] [COLOR=#0000FF]virtual[/color] [COLOR=#0000FF]void[/color] Dispose([COLOR=#0000FF]bool[/color] Disposing)
        {
            [COLOR=#0000FF]if[/color] (Disposing)
            {
                [COLOR=#0000FF]if[/color] (_IDbConnection != [COLOR=#0000FF]null[/color])
                {
                    _IDbConnection.Dispose();
                    _IDbConnection = [COLOR=#0000FF]null[/color];
                }
            }
        }
        [COLOR=#008000]/*[/color]
[COLOR=#008000]         * methods that any class using this library can plug into if they want to see[/color]
[COLOR=#008000]         * Query events. Show finally query statement that is being run[/color]
[COLOR=#008000]         * Useful if you are having problems with a stored procedure and need to verify its[/color]
[COLOR=#008000]         * SQL syntax.[/color]
[COLOR=#008000]         */[/color]
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]delegate[/color] [COLOR=#0000FF]void[/color] [COLOR=#2B91AF]OnQueryHandler[/color]([COLOR=#0000FF]object[/color] sender, [COLOR=#2B91AF]QueryArgs[/color] e);
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]event[/color] [COLOR=#2B91AF]OnQueryHandler[/color] OnQuery;
        [COLOR=#0000FF]private[/color] [COLOR=#0000FF]void[/color] TriggerQuery([COLOR=#0000FF]string[/color] queryString)
        {
            [COLOR=#0000FF]if[/color] (OnQuery == [COLOR=#0000FF]null[/color]) [COLOR=#0000FF]return[/color];
            OnQuery([COLOR=#0000FF]this[/color], [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]QueryArgs[/color](queryString));
        }
        [COLOR=#0000FF]public[/color] [COLOR=#0000FF]class[/color] [COLOR=#2B91AF]QueryArgs[/color] : [COLOR=#2B91AF]EventArgs[/color]
        {
            [COLOR=#0000FF]public[/color] [COLOR=#0000FF]string[/color] QueryString { [COLOR=#0000FF]get[/color]; [COLOR=#0000FF]private[/color] [COLOR=#0000FF]set[/color]; }
            [COLOR=#0000FF]public[/color] QueryArgs([COLOR=#0000FF]string[/color] QueryString)
            {
                [COLOR=#0000FF]this[/color].QueryString = QueryString;
            }
        }
    }
}
 
My application will be run on a non-Micros computer that is on the same network as the Micros server.I have gone back and forth on different connection strings and found that running the Micros 5.1 pre-req on the computer that will run the application resolved all connectivity issues.

That seems to setup the ODBC connecitons for 32 or 64 bit OS. Everything seems to play nice now. Thanks for all the help on this, I have learned so much from assistance on this forum.
 
Yep. The pre-req installs all of the database drivers. The only thing you'll have to look out for is upgrading. When you go to Res 5.2 MR1a or higher the database is upgraded to Sybase 16, and the Sybase 11 drivers won't connect to it. Running the 5.2 pre-req will uninstall the v11 drivers and install v16. Not a problem if you're only connecting to one Micros system, but the programs I have are looping through 22 locations running anything from 4.11 to 5.4 so I need multiple drivers on the client machine. It looks like v16 has some backwards compatibility though and might eliminate that need. I'll test it out when I have a few free minutes, probably some time around July 2017, lol.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top