![]() | Register | FAQ | Members | Social Groups | User Map | Calendar | Search | Today's Posts | Mark Forums Read |
| | | LinkBack | Thread Tools | Search Thread | Language |
| Sponsored Links |
| | #1 |
![]() Join Date: Oct 2006 Location: Gloucester
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 5 | So I successfully changed the script and it works… however I had a problem with the Date (so does the original but as its for tracking students in IT rooms its ok), I guess some of the laptops must have American regional settings as it doesn’t insert a row when I include the date field (with a couple of exceptions)… so I was wondering rather than the script inserting the date can I get the server to automatically append the date to the row when it detects an insert? (I could also get rid of my Time Colum if I get the date field to work correctly…) Original snippet (only caught some users because of the date field) Code: s = Wshnetwork.computername
nm = wshnetwork.username
theTime = FormatDateTime (now(),4)
theDate = Date()
s_sql = "INSERT INTO Teach_Sign (SignUser, SignComputer, SignTime, SignDate) VALUES ('" & nm & "','" & s & "','" & theTime & "','" & theDate & "')"
m_rs.open s_SQL, m_cn, adOpenStatic
My Script Snipit that works… but cause I removed the date field they all appear as 01/01/1900 00:00 Code: s_sql = "INSERT INTO Teach_Sign (SignUser, SignComputer, SignTime) VALUES ('" & nm & "','" & s & "','" & theTime & "')"
Thanks Gordy. |
| |
| | #3 |
![]() Join Date: Oct 2006 Location: Warwickshire
Posts: 91
Thanks: 1
Thanked 17 Times in 12 Posts
Rep Power: 7 | When you create the table, if you set the default value for the SignDate field as the MS SQL function GetDate(), the server will automatically insert the current date and time when the record is created (if you do not specify a value in the INSERT query)..... MS SQL: Code: CREATE TABLE [Teach_Sign] ([SignUser] varchar(25) NOT NULL, [SignComputer] varchar(25) NOT NULL, [SignDate] datetime DEFAULT GetDate()); Then all you should need to do is insert the username and computername (using your origional code)...... Code: s = wshnetwork.computername
nm = wshnetwork.username
s_sql = "INSERT INTO Teach_Sign (SignUser, SignComputer) VALUES ('" & nm & "','" & s & "')"
m_rs.open s_SQL, m_cn, adOpenStatic
Iain. |
| |
| | #4 |
![]() Join Date: Oct 2006 Location: Gloucester
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 5 | Thanks Iain the Default GetDate() gave me the clue.. so I found the Colum in the SQL database and put this in as the default value removed the date and time from the insert and the time Colum for the DB and it now works a treat !!! Thanks... |
| |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SIMS on MSSQL 2005 | AlexB | MIS Systems | 9 | 07-11-2007 10:20 AM |
| Open Source CMS that can use MSSQL | ICTNUT | Windows | 4 | 29-03-2007 03:08 PM |
| WSUS & Sophus - MSSQL ?? | tech_master | Windows | 3 | 18-01-2007 07:22 PM |
| MSSQL Trigger (i think) Question | k-strider | Coding | 0 | 27-11-2006 12:45 PM |
| Autocreate AD accounts from MSSQL | CyberNerd | Coding | 9 | 12-07-2006 03:00 PM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
|
|





