I'm trying to pull the windows username with jscript and save it to ms access field in a table, but it does not work. it does show the alert with the name of the user but does not save it to the ms access field. here i steh code that i'm using. please help
Expand|Select|Wrap|Line Numbers
- <SCRIPT type=text/javascript>
- <!--
- var WinNetwork = new ActiveXObject("WScript.Network");
- alert(WinNetwork.userName);
- var adOpenDynamic = 2;
- var adLockOptimistic = 3;
- /* Path of database.
- */
- var strDbPath = "C:\Documents and Settings\ASPIRE\Desktop\ss1 upgrade\SS1\db1";
- /*
- Here is the ConnectionString for Microsoft Access.
- */
- var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbPath;
- function AddRecord() {
- var adoConn = new ActiveXObject("ADODB.Connection");
- var adoRS = new ActiveXObject("ADODB.Recordset");
- adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\db1.mdb'");
- adoRS.Open("Select * From TimeTrackerTable Where Group = 'xxxx'", adoConn, 1, 3);
- adoRS.AddNew;
- adoRS.Fields("Group").value = "(WinNetwork.userName)";
- adoRS.Update;
- adoRS.Close();
- adoConn.Close();
- }
- function getAdoDb(strAdoType){
- if (window.ActiveXObject){
- return new ActiveXObject(strAdoType);
- }
- else{
- return ActiveXObject(strAdoType);
- }
- }
- </SCRIPT>
- <INPUT id=Button1 onclick=EditRecord() type=button name=Command0 ;><BR>
- <SCRIPT language=javascript event=onclick for=Command0>
- try { if (MSODSC.DataPages.Count > 0)
- if (MSODSC.CurrentSection == null)
- MSODSC.DataPages(0).Save();
- else
- MSODSC.CurrentSection.DataPage.Save(); }
- catch (e)
- { alert (e.description);}
- </SCRIPT>
xx