Z
zdrakec
Hello all:
Please consider the following snippet:
Dim cn As New OdbcConnection
Dim cm As New OdbcCommand
Dim result As Object
cn.ConnectionString = AValidConnectionString
cn.Open()
cm.Connection = cn
cm.CommandType = CommandType.Text
cm.CommandText = AValidQuery
cm.Parameters.Add(AValidODBCParameterObject)
result = cm.ExecuteScalar
Although the query is a straightforward select that will
return at most one row and one column, and the query, when run in Query
Analyzer, in fact returns this value, ExecuteScalar is returning
Nothing.
The query is simple: "SELECT lastname FROM users WHERE userkey = ?"
The parameter is equally simple: name = "@userkey",value = 25 (for
example).
The only anomaly I can find is when I inspect the parameter, it
declares itself to have a DbType of String, and ODBCDbType of NVarChar,
when it should be Int32 and Int, respectively. It retains this setting
even when I explicitly set it.
Any ideas?
Thanks much,
zdrakec
Please consider the following snippet:
Dim cn As New OdbcConnection
Dim cm As New OdbcCommand
Dim result As Object
cn.ConnectionString = AValidConnectionString
cn.Open()
cm.Connection = cn
cm.CommandType = CommandType.Text
cm.CommandText = AValidQuery
cm.Parameters.Add(AValidODBCParameterObject)
result = cm.ExecuteScalar
Although the query is a straightforward select that will
return at most one row and one column, and the query, when run in Query
Analyzer, in fact returns this value, ExecuteScalar is returning
Nothing.
The query is simple: "SELECT lastname FROM users WHERE userkey = ?"
The parameter is equally simple: name = "@userkey",value = 25 (for
example).
The only anomaly I can find is when I inspect the parameter, it
declares itself to have a DbType of String, and ODBCDbType of NVarChar,
when it should be Int32 and Int, respectively. It retains this setting
even when I explicitly set it.
Any ideas?
Thanks much,
zdrakec