WinScripter is a great resource if you haven't come across it yet.
Check out this page.
http://www.winscripter.com/wsh/database/dsnless.asp
I modified the above example to query a remote sql server and output
the results into the current open document in Homesite. Worked like a
charm...
function Main() {
var ad = new ActiveXObject( "ADODB.Recordset" );
var cString = "Driver={SQL Server};Server=ipaddress;Database=dbname;Uid=username;Pwd=password";
var sql = "Select TOP 10 * FROM Parts";
ad.Open( sql, cString, 1, 3 );
while( !ad.EOF ) {
// variable to store data
record = "";
// Loop through each field in this record
// and add contents to variable
// Starting field set to 1 to skip record id field. Use 0 for all fields
for( i = 1; i < ad.Fields.Count; i++ )
record += ad(i) + "\n";
// Display the contents in Homesite
Application.ActiveDocument.InsertText(record, false);
//Move to the next record and loop
ad.MoveNext();
}
ad.Close();
}
Just a recommendation, not knowing your cursor experience, but
understanding cursors is a prerequisite to understanding ADO. Once you
figure out how cursors work with ADO, it all falls into place.
--
mailto:[EMAIL PROTECTED]
Saturday, October 11, 2003, 3:54:07 AM, you wrote:
HO> So I've spent most of the day trying to figure out (and doing lots of searches on the web) on how to use Scripting to access SQL Server (again, I'm trying to run this through HomeSite+ scripting).
HO> If I do something like
HO> var objConn = Server.CreateObject(ADODB.Connection);
HO> I get an error that Server isn't defined.
HO> So I tried every way I could think of or get a clue to define Server.
HO> Among those I tried were:
HO> Server = ActiveXObject(ADODB.Connection);
HO> And
HO> var Server= "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=articles;Data Source=me" ;
HO> And a million other variations, probably.
HO> Anybody have any idea how to do this?
HO> H.
HO>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

