Here's 3 methods:
1.
We something like this in our current app, only it's VBScript, and not VB.NET. One of our guys found a C#-based VBScript interpreter, which you could translate into VB.NET, or left as C# and put in it's own assembly (probably the best solution). Do some googling to find it.
2.
If you want to load compiled (binary) VB.NET code from your database, look at the Assembly.Load() overloaded method, one of which accepts a byte array. This array of bytes should be the binary image of an assembly.
3.
If you want to run raw VB.NET code, you'd do something like this (sorry for any C#-isms):
[tt]
Dim myCodeProvider as new VBCodeProvider()
Dim myCompiler as ICodeCompiler
myCompiler = myCodeProvider.CreateCompiler()
Dim cp as New CompilerParameters()
cp.GenerateInMemory = true
cp.IncludeDebugInformation = true
cp.MainClass = "foo"
cp.OutputAssembly = "customassemblyfromdb"
cp.ReferencedAssemblies.Add("System.dll")
cp.WarningLevel = 4
cp.TreatWarningsAsErrors = true
Dim cr as CompilerResults
cr = myCompiler.CompileAssemblyFromSource(cp, "the string containing VB.NET statements goes here")
if (cr.Errors.Count > 0) Then
' Something didn't compile. Uh-Oh.
else
Dim a as Assembly
a = cr.CompiledAssembly
Dim mi as MethodInfo
mi = a.EntryPoint
Object[] parms = new [Object]() {23, "hello" }
Object o = mi.Invoke(null, parms)
end if
[/tt]
Note that you'll want to define a common interface to be used by your stored code so that you're (somewhat) assured that the method signature on your entry point will match up to the code you're calling it with.
Chip H.
____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first