Archive
Three new sites launched
Just completed three new sites. SQL server 2005 back end, with ASP 2.0
http://www.listofbuilders.info
http://www.listofElectricians.info
http://www.listofrestaurants.info/
All pretty much the same, but I was just learning about templates.
COM interoperability with Matlab 7 in C#
If you try to import Matlab 7.0’s com object into C#, you get this error when you try to call it using early binding.
MLApp.MLAppClass MyMatlab = new MLApp.MLAppClass();
textBox1.Text = MyMatlab.Execute("version");
results in:
An unhandled exception of type ‘System.InvalidCastException’ occurred
in Test version7.exe
Additional information: QueryInterface for interface MLApp.DIMLApp
failed.
This is apparently due to a mix up with GUID’s for mlapp.tlb, so, instead of hacking with the registry to correct their GUID, you can alternatively use late binding on the object thus;
Type objFactoryType;
objFactoryType = Type.GetTypeFromProgID("Matlab.Application");
object objFactory;
objFactory = Activator.CreateInstance(objFactoryType);
object[] args = new object[1];
args[0]="version";
object retval;
retval = objFactoryType.InvokeMember("Execute",BindingFlags.InvokeMethod,null,
objFactory,args);
MessageBox.Show(retval.ToString());
Which works fine…
Accessing a database with Macomedia Director
Working on a university project which included a need for Macromedia Director to access a database (in my case, MS Access). I downloaded ADOXTRA.X32 from XtraMania.com, copied it into my D:Program FilesMacromediaDirector 8.5Xtras folder, then with a bit of tinkering, I wrote the following Lingo function:
on GetDatabaseField (SQL,Column)
ADO = xtra("ADOxtra")
ADO.Init(true)
gRst = ADO.CreateObject(#Recordset)
gRst.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Read;Data Source=" & the moviePath & "prototype.mdb"
gRst.cursorLocation=gRst.adUseClient
gRst.LockType=gRst.adLockReadOnly
gRst.CursorType=gRst.adOpenStatic
gRst.Source=SQL
gRst.Open()
if gRst.Failed then
alert gRst.LastError
halt
end if
gRst.MoveFirst()
retVal = gRst.fields[Column]
gRst.Close()
return retVal
end
Which is called with something along the lines as:
on
mouseDown me
set the text of member "DynamicText" = GetDatabaseField ("select firstname from people where id = 1 ","firstname")
end