To get ID of Selected RadioButton using jQuery (change nameOfRadio to actual radio name)
var id = $("input:radio[name=nameOfRadio ]:checked").attr('id');
Monday, January 31, 2011
Thursday, October 14, 2010
Luhn Checksum in Foxpro
Based on Excel Vba from http://www.excelforum.com/excel-programming/482390-excel-vba-calculating-checksums.html
?IsLuhnChecksumOK("0000000000000000")
Function IsLuhnChecksumOK(Number_String)
Local Digit
Local i
Local N
Local Result
Local SumDigits
Local nDigits
N = 0
SumDigits = 0
nDigits = Len(Number_String)
For i = nDigits To 1 Step -1
Digit = Val(Substr(Number_String, i, 1))
N = N + 1
If Mod(N , 2) = 0
Digit = Digit * 2
Endif
If Digit > 9
Digit = Digit - 9
Endif
SumDigits = SumDigits + Digit
Next i
Result = Mod(SumDigits ,10)
Return Result = 0
Endfunc
Function GetLuhnCheckDigit(Number_To_Check)
Local J As Integer
Local X
X = IsLuhnChecksumOK(Number_To_Check)
If X = False Then
For J = 0 To 9
X = IsLuhnChecksumOK(Bitand(Number_To_Check , J))
If X = True
*'Check digit found
*GetLuhnCheckDigit = J
Return J
Endif
Next J
Else
*'No check digit needed returns -1
Return -1
Endif
Endfunc
?IsLuhnChecksumOK("0000000000000000")
Function IsLuhnChecksumOK(Number_String)
Local Digit
Local i
Local N
Local Result
Local SumDigits
Local nDigits
N = 0
SumDigits = 0
nDigits = Len(Number_String)
For i = nDigits To 1 Step -1
Digit = Val(Substr(Number_String, i, 1))
N = N + 1
If Mod(N , 2) = 0
Digit = Digit * 2
Endif
If Digit > 9
Digit = Digit - 9
Endif
SumDigits = SumDigits + Digit
Next i
Result = Mod(SumDigits ,10)
Return Result = 0
Endfunc
Function GetLuhnCheckDigit(Number_To_Check)
Local J As Integer
Local X
X = IsLuhnChecksumOK(Number_To_Check)
If X = False Then
For J = 0 To 9
X = IsLuhnChecksumOK(Bitand(Number_To_Check , J))
If X = True
*'Check digit found
*GetLuhnCheckDigit = J
Return J
Endif
Next J
Else
*'No check digit needed returns -1
Return -1
Endif
Endfunc
Friday, October 1, 2010
NHibernate.Driver.SQLite20Driver Exception
To fix below error, make sure to add reference System.Data.Sqlite and Copy Local = True in the properties window.
FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
* Database was not configured through Database method.
----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver.
----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly.
FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
* Database was not configured through Database method.
----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver.
----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use
Labels:
Nhibernate,
Sqlite
Tuesday, July 27, 2010
Excel last row column
lnLastRow = loExcel.activesheet.UsedRange.ROWS.COUNT
lnLastCol = loExcel.activesheet.UsedRange.COLUMNS.COUNT
lnLastCol = loExcel.activesheet.UsedRange.COLUMNS.COUNT
Labels:
Excel
Monday, July 26, 2010
Excel Fit to page using Foxpro Automation
loExcel.ActiveSheet.PageSetup.Zoom = .f.
loExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
loExcel.ActiveSheet.PageSetup.FitToPagesTall = 1
loExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
loExcel.ActiveSheet.PageSetup.FitToPagesTall = 1
Wednesday, July 29, 2009
Resize dbf column length to maximum content length
lnSelect = SELECT()
lcAlias = ALIAS()
USE DBF() EXCLUSIVE
lnFields = AFIELDS(aa)
FOR i = 1 TO lnFields
lcField = aa[i, 1]
lcType = aa[i,2]
lnOrigLen = aa[i, 3]
IF lcType = 'C'
SELECT MAX(LEN(ALLTRIM(&lcField))) maxlen FROM (lcAlias) INTO ARRAY curlen
lnLen = IIF(curlen = 0, 1, curlen)
IF lnOriglen > lnLen
ALTER table (lcAlias) alter COLUMN (lcField) c(lnLen)
?lcField, curlen
ENDIF
ENDIF
ENDFOR
SELECT (lnSelect)
RETURN
lcAlias = ALIAS()
USE DBF() EXCLUSIVE
lnFields = AFIELDS(aa)
FOR i = 1 TO lnFields
lcField = aa[i, 1]
lcType = aa[i,2]
lnOrigLen = aa[i, 3]
IF lcType = 'C'
SELECT MAX(LEN(ALLTRIM(&lcField))) maxlen FROM (lcAlias) INTO ARRAY curlen
lnLen = IIF(curlen = 0, 1, curlen)
IF lnOriglen > lnLen
ALTER table (lcAlias) alter COLUMN (lcField) c(lnLen)
?lcField, curlen
ENDIF
ENDIF
ENDFOR
SELECT (lnSelect)
RETURN
Labels:
Foxpro
Tuesday, April 14, 2009
Grant Execute Role
Granting execute permissions to all stored procedures in a database
CREATE ROLE db_executor
GRANT EXECUTE TO db_executor
from article on SqlDbaTips.com
CREATE ROLE db_executor
GRANT EXECUTE TO db_executor
from article on SqlDbaTips.com
Labels:
Sql Server
Subscribe to:
Posts (Atom)