Well, there are many ways to obtain this. As its christmas, and you have plenty of time for reading, try the following!...
Have a look in the GLOBAL.ASA file in the root of your app. You will (should) see a range of connection strings added to the APPLICATION collection.
Application("cnCON_User_ConnectionString"

= "Provider=MSDASQL.1;User ID= ..... etc...
If you expose (the code of) one of your recordset DTC's, then you may see these settings being used - something like this:
var DBConn = Server.CreateObject('ADODB.Connection');
DBConn.ConnectionTimeout
= Application('cnCON_User_ConnectionTimeout');
DBConn.CommandTimeout
= Application('cn_User_CommandTimeout');
DBConn.CursorLocation
= Application('cnCON_User_CursorLocation');
DBConn.Open(Application('cnCON_User_ConnectionString'),
Application('cnCON_User_RuntimeUserName'),
Application('cnCON_User_RuntimePassword'));
var cmdTmp = Server.CreateObject('ADODB.Command');
var rsTmp = Server.CreateObject('ADODB.Recordset');
cmdTmp.ActiveConnection = DBConn;
rsTmp.Source = cmdTmp;
cmdTmp.CommandType = 1;
cmdTmp.CommandTimeout = 10;
cmdTmp.CommandText = 'SELECT * FROM tblTable';
...etc... [put your INSERT command above]
You may be able to add a RECORDSET DTC, that includes the INSERT clause - this has the benefit of wrapping any PARAMETERS, so you can insert like this:
(DTC called
rsInsert)
INSERT (c1, c2, c3) VALUES (?, ?, ?)
make sure you un-tick the AutoOpen option for this recordset!
Then set the column values via parameters...
rsInsert.setParameter 0, txtValue1
rsInsert.setParameter 1, txtValue2
..etc..
rs.Open
rs.Close
(now refresh the grid recordset to see the new row - assuming the Recordset Query does not Filter it out!!!)
this has the benefit that you do not need to care about single/double quotes within the txtValue's.
FINALLY: The above method is OK, but if you want to do the same function on other web pages, then you could consider using the DataEnvironment. Just add the INSERT as a Command - locate the GLOBAL.ASA, right click a connection and add a command - call it
insMyInsert. Type in the INSERT clause. Then in your web page:
thisPage.createDE
intResult = DE.
insMyInsert txtValue1, txtValue2, txtValue3
Again, refresh the Grid Recordset - if its WHERE clause allows, then the new row will show somewhere in the list.
***New Year Teaser...***
If you feel up to it, you could add an extra 'row' to the Grid via an event for an ADD function:
I have added a total-row event - so I can add sum totals to the bottom of a grid, you could adjust it for an ADD row:
in the middle of the
function _DG_display(bReturnText)
if (objRS.EOF) {
@if (@trace_events)
thisPage._traceEvent(this.name,GRID_ONTOTALROW);
Response.Write ('<br>EVENT TRACE: <b>' + this.name + '</b> fired <b>' + GRID_ONTOTALROW + '</b> event.');
@end
this._objEventManager.fireEvent(GRID_ONTOTALROW);
}
and in the
function _DataGrid(strName,objParent)
add:
// advise for eventhandlers
this._objEventManager = CreateEventManager();
this._objEventManager.adviseDefaultHandler(this.name,GRID_ONDISPLAY);
this._objEventManager.adviseDefaultHandler(this.name,GRID_ONTOTALROW);
and in your web page code:
Function grdGrid_ontotalrow()
dim strHTML
strHTML = "<TR>"
strHTML = strHTML & "<TD><Font Size=2><B>**Add New**</TD>"
/*add INPUT text boxes in the HTML string..*/
strHTML = strHTML & "</TR>"
grdGrid.insertRow strHTML
End Function
HAPPY NEW YEAR (Content Management)