I helped @xvhelp privately because I thought he was doing something a bit different.
Turns out he was not. He was calling a stored procedure in another database and just
wanted to patch up his code to call it.
Here is what we ended up with, since we just wanted to keep what he had going,
without moving to a new library.
//using System.Reflection
Assembly System_Data_SqlClient = Assembly.Load("System.Data.SqlClient");
Type typeSqlCommand = System_Data_SqlClient.GetType("System.Data.SqlClient.SqlCommand");
Type typeSqlConnection = System_Data_SqlClient.GetType("System.Data.SqlClient.SqlConnection");
dynamic conn = Activator.CreateInstance(typeSqlConnection, "Data Source=MYDBServer;Initial Catalog=MYDB; User ID=MYID;Password=MYPASSWORD");
conn.Open();
string cmdText = "my_stored_proc"; //sql commands
dynamic command = Activator.CreateInstance(typeSqlCommand, new object[]{ cmdText, conn });
command.CommandType = System.Data.CommandType.StoredProcedure;
command.ExecuteNonQuery();
conn.Close();
Edit: How did those damn fancy quotes get in there?