15 Oct 17:40
Interactive C# - running a script
From: Daniel Morgan <monodanmorg <at> yahoo.com>
Subject: Interactive C# - running a script
Newsgroups: gmane.comp.gnome.mono.devel
Date: 2008-10-15 15:41:58 GMT
Subject: Interactive C# - running a script
Newsgroups: gmane.comp.gnome.mono.devel
Date: 2008-10-15 15:41:58 GMT
I would like to use the csharp interactive shell to run a script file.
Is this possible?
Here is an example (not tested):
linux$ cat script-file > csharp
Connecting...
Copying...
Done.
linux$
Example script (not tested):
LoadLibrary("System.Data.dll");
LoadLibrary("System.Data.OracleClient");
using System.Data;
using System.Data.SqlClient;
using System.Data.OracleClient;
Console.WriteLine("Connecting...");
SqlConnection sourcedb = SqlConnection("...");
sourcedb.Open();
SqlCommand sourceCmd = sourcedb.CreateCommand();
sourceCmd.CommandText = "SELECT somecolumn FROM sometable WHERE C = 'A'";
string value = (string) sourceCmd.ExecuteScalar();
OracleConnection targetdb = OracleConnection("...");
targetdb.Open();
Console.WriteLine("Copying...");
OracleCommand targetCmd = targetdb.CreateCommand();
targetCmd.CommandText = "INSERT INTO sometable (column1) VALUES ('" + value + "')";
(Continue reading)
RSS Feed