UniConnection conn = new UniConnection();
//Connecting to Oracle server through OraDirect .NET
conn.ConnectionString = "provider=OraDirect;Password=tiger;User Id=Scott;Host=ora920;";
//Define macros for tables dept
UniMacro mac = new UniMacro("tablename", "test.dept", "MySQL");
conn.Macros.Add(mac);
UniMacro mac2 = new UniMacro("tablename", "dept", "Oracle");
conn.Macros.Add(mac2);
//Define query that uses the macro
UniCommand cmd = new UniCommand("SELECT Count(*) FROM {tablename}");
cmd.Connection = conn;
conn.Open();
try {
//Run the query and make sure it is executed correctly
string response = cmd.ExecuteScalar().ToString();
MessageBox.Show(response);
}
finally {
conn.Close();
}