What are your "raw materials" -- will you have one file with a bunch
of T-SQL for MSSQL, and a separate file with a bunch of PL/SQL for
Oracle?  Or are you trying to implement some logic in the code itself,
that will "just work" on various database platforms?

If the latter, this is a rather difficult problem.  Project like
NHibernate and FluentMigrations exist in this space... it is some
effort to learn how to use them, and they don't do everything anyway
(*especially* in the area of DDL / sprocs / etc.).

If the former, there are plenty of C# and VB.NET examples out there;
the general pattern is below... You should be able to adapt this to
Powershell with the [new-object] mumbo jumbo... this stuff is in the
System.Data.Common namespace:

/* 'factory' is the invariant name of a DbProviderFactory known to the
.NET runtime, registered either in app.config or machine.config */
var factory = DbProviderFactories.GetFactory(factory);
var conn = factory.CreateConnection();

/* 'cstr' is a database-specific connection string; something like
'Data Source=.;Initial Catalog=foo' for MSSQL */
conn.ConnectionString = cstr;
conn.Open();

/* now do stuff */
var cmd = conn.CreateCommand();
cmd.CommandText = "select * from blar"; // or pull commands from a file

--Steve

2012/4/2 Joseph L. Casale <[email protected]>:
> I have to make a ps script that is portable for use with MSSQL and Oracle 
> backends to apply regular
> schema updates then reload stored procs.
>
> Starting with SQL half first, there is plenty of sample code for running 
> individual statements against
> an SQL server but that means rewriting the script each time. Anyone know a ps 
> method using the
> DbCommand Class to play a script into the database?
>
> Thanks!
> jlc
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to