I am using installscript to call a sql database. If I use objects like "ADODB.Connection" it all works fine. I can loop through a recordset and create a LIST object to return. However, I was wishing to return a "System.Data.DataTable" so that the calling methods could more easily deal with table data. So I have written some code to use classes like "System.Data.SqlClient.SqlConnection" and "System.Data.DataTable" etc.
The problem is, objects seem to get created but I cannot set properties of them.
I got this working for a simple example (from a website) using "System.Collections.ArrayList" as follows:
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Use .net datatables/sqlconnection wi
Started by
pauldavidson
, Nov 29 2012 18:14
4 replies to this topic
Posted 29 November 2012 - 18:14
CODE |
set colors = CoCreateObject( "System.Collections.ArrayList"); colors.Add( "RED" ); colors.Add( "WHITE" ); colors.Add( "BLUE" ); NumToStr(TempString, colors.Count); MessageBox(TempString + " colors exist", INFORMATION); |
However I cannot get it working for other objects, the first being the SqlConnection object.
I have the following:
CODE |
set SqlConnectionObject = CoCreateObject("System.Data.SqlClient.SqlConnection"); SqlConnectionObject.ConnectionString = szConnString; |
The second lines throws an error with no description or source.
Any ideas?
Posted 01 December 2012 - 14:45
I'm not sure. Did you add some error checking to see if the object was successfully created?
Stefan Krüger
InstallSite.org twitter facebook
Posted 03 December 2012 - 14:38
If there was an exception on the first line of code, surely it wouldn't drop down to the second line where it attempts to use the object? I ended up giving up on this one as I could not figure out what was wrong.
So I have just used the standard ado objects, it just isn't as good to use as the other objects.
So I have just used the standard ado objects, it just isn't as good to use as the other objects.
Posted 03 December 2012 - 20:44
QUOTE |
If there was an exception on the first line of code, surely it wouldn't drop down to the second line where it attempts to use the object? |
I think it would.
Stefan Krüger
InstallSite.org twitter facebook
Posted 05 December 2012 - 15:40
Fair enough, when I am getting back to look at that code, I will check for the error.