Posted by Nancy on December 1, 2009
ETA: 2009.12.02: This code is in version 8. As the inimitable Doug Hennig (fangirl squeal) points out in comments, VFP 9 TTOC() has a new flag for returning an XML DateTime format. I would still use one of the options below because they are version-neutral, and because Set Date Short | Long affects the return value (the setting from Windows Control Panel is used).
Well, that and because sometimes one simply must write code that makes one giggle.
Silly, but this code amuses me.
? Stuff( ;
Stuff( ;
Stuff( ;
Stuff( ;
Stuff( Ttoc( Datetime(), 1 ), 13, 0, ':'), ;
11, 0, ':'), ;
9, 0, ' '), ;
7, 0, '.'), ;
5, 0, '.')
ETA (2009.12.02): Another way to do the same thing as above is the following:
?Transform( Year( Date() ) ) + "." + ;
Padl( Transform( Month( Date() ) ), 2, "0" ) + "." + ;
Padl(Transform( Day( Date() ) ), 2, "0" ) + " " + ;
Padl(Transform( Hour( Datetime() ) ), 2, "0" ) + "." + ;
Padl(Transform( Minute( Datetime() ) ), 2, "0" )+ "." + ;
Padl(Transform( Sec( Datetime() ) ), 2, "0" )
*Yawn*
Posted in FoxPro | Tagged: datetime, string, stuff, VFP | 6 Comments »
Posted by Nancy on November 30, 2009
Opening an existing Asp.Net 1.1 solution on my development machine resulted in this error message. Restarting IIS didn’t resolve it, nor did repairing the .NET installation. In combination, though, as suggested by NewGuy in this old post did the trick. I had to stop IIS, delete the asp.net user, repair the framework installation, then restart IIS.
First time for this particular problem. Thanks to experienced people contributing to public fora.
Eta: deleting the asp.net user.
Posted in Asp.Net 1.1 | Tagged: "HTTP/1.1 500 Internal Server Error" ASP.NET 1.1 | Leave a Comment »
Posted by Nancy on November 18, 2009
Posted in Software development | Leave a Comment »
Posted by Nancy on November 16, 2009
I updated my post from yesterday to set the default value for date and datetime fields. A better choice than {} is .NULL., since SQL Server doesn’t understand empty dates the same way VFP does.
Posted in Software development | Tagged: 9, date, datetime, defaultvalue, sql server, VFP | Leave a Comment »
Posted by Nancy on November 16, 2009
Remote views on SQL Server data must have default values. That’s tedious. Luckily it was fairly straightforward to write code to do it for me based on type.
Warning: If you use this code, use it at your own risk. Back up your data first, and test it before using it on production data. Also, note that in this case, I’m just setting values for fields in views.
_SetDefaults("YourDBC")
Return
Procedure _SetDefaults(tcDbc)
Local lcDBC, lcDefault, lcType, lcFld
lcDBC = Forceext(tcDbc, 'dbc')
Select Alltrim(tbl.objectname) + "." + ;
Alltrim(fld.objectname) As FieldName ;
From (lcDBC) tbl ;
Inner Join (lcDBC) fld On ;
fld.parentid = tbl.objectid ;
Where tbl.objecttype="View" ;
Into Cursor lvw
Use In Select(Juststem(lcDBC))
Open Database (lcDBC)
Set Database To (Juststem(lcDBC))
Scan
lcFld = Alltrim(FieldName)
lcDefault = DBGetProp(lcFld ,"Field","DefaultValue")
If !Empty(lcDefault)
Loop
Endif
lcType = Left(DBGetProp(lcFld ,"Field","DataType"), 1)
Do Case
Case Inlist(lcType, 'C', 'M')
DBSetProp(lcFld,"Field","DefaultValue","''")
Case lcType = "L"
DBSetProp(lcFld,"Field","DefaultValue",".F.")
Case Inlist(lcType, 'D', 'T')
DBSetProp(lcFld,"Field","DefaultValue",".NULL.")
Case Inlist(lcType, 'N', 'Y')
DBSetProp(lcFld,"Field","DefaultValue","0")
Endcase
Endscan
Close Tables All
Close Databases All
Endproc
Updated 2009.11.16: default value for dates and datetimes should be .NULL. instead of {}. Dates will come back bogus otherwise, since SQL Server doesn’t understand empty dates the same way VFP does.
Posted in Software development | Tagged: defaultvalue, VFP | 1 Comment »