Invalid use of null via ODBC? (1 Viewer)

Kowalski

Registered User.
Local time
Today, 17:52
Joined
Jul 5, 2007
Messages
121
We've got an Access application that connects to either a SQL database or to an Access database.
Now we found 1 or 2 pc's where, if connected to SQL (via ODBC) you get an "Invalid use of Null" error when changing any currency or date fields. It's not in the application as in only happens on 1 or 2 pc's. Changing the regional settings of the pc doesn't help.
(We are using the default ODBC settings, so the "Use regional settings..." setting is not selected - but selecting it does not solve the problem)
 

peej228

New member
Local time
Today, 07:52
Joined
Oct 21, 2006
Messages
5
Sql Server Nulls passed to a Date Data Type

Nulls cannot be passed to a Date data type with sql server.
You can create a date in access without a value and pass that to the parameter

'For currency
dim dblValue as double
dblValue = val(nz(me.txtCurrency,0))
'Pass dblValue normally


dim DtValue as Date


dim cmd as adodb.command
cmd.ActiveConnection = cn 'Assign your connection here
cmd.CommandType = adCmdUnknown
cmd.CommandText = strSQL 'Assign SQL statement here

Set Param = cmd.CreateParameter(, adDate, adParamInput, 50, dtValue)
cmd.Parameters.Append Param
set Param = nothing
cmd.Execute
set cmd = nothing
 

Users who are viewing this thread

Top Bottom