ODBC.NET Data Provider to connect to Oracle

  • Thread starter Reny J Joseph Thuthikattu
  • Start date
R

Reny J Joseph Thuthikattu

Hi,
In My Oracle table i have severla fields in that i want to filter the result
based on two Date fileds and One Number field .I am using ODBC.NET Data
Provider to connect to Oracle.The TIMEOFCONTACT filed format is 'HH24:MI:SS'
i.e contain onlly yhe time

The SQL is like this
select * from RECORDS_T WHERE DATEOFCONTACT = ? AND TIMEOFCONTACT=? AND
CONTACT_NUMBER =? "

Dim cmd As New OdbcCommand(sqlstr, OdbcConn)

OdbcConn.Open()

cmd.Parameters.Add("DATEOFCONTACT", OdbcType.Date, 0, "DATEOFCONTACT").Value
= dateOfcall

cmd.Parameters.Add("TIMEOFCONTACT", OdbcType.DateTime, 0,
"TIMEOFCONTACT").Value = TIMEOFCONTACT

cmd.Parameters.Add("CONTACT_Number", OdbcType.Decimal, 0,
"CONTACT_NUMBER").Value = CONTACT_No

OdBcOdr = cmd.ExecuteReader(CommandBehavior.SingleResult)

At this point i am getting no result even though there is value in the DB.



Can any one help me out

Reny
 
P

Paul Clement

¤ Hi,
¤ In My Oracle table i have severla fields in that i want to filter the result
¤ based on two Date fileds and One Number field .I am using ODBC.NET Data
¤ Provider to connect to Oracle.The TIMEOFCONTACT filed format is 'HH24:MI:SS'
¤ i.e contain onlly yhe time
¤
¤ The SQL is like this
¤ select * from RECORDS_T WHERE DATEOFCONTACT = ? AND TIMEOFCONTACT=? AND
¤ CONTACT_NUMBER =? "
¤
¤ Dim cmd As New OdbcCommand(sqlstr, OdbcConn)
¤
¤ OdbcConn.Open()
¤
¤ cmd.Parameters.Add("DATEOFCONTACT", OdbcType.Date, 0, "DATEOFCONTACT").Value
¤ = dateOfcall
¤
¤ cmd.Parameters.Add("TIMEOFCONTACT", OdbcType.DateTime, 0,
¤ "TIMEOFCONTACT").Value = TIMEOFCONTACT
¤
¤ cmd.Parameters.Add("CONTACT_Number", OdbcType.Decimal, 0,
¤ "CONTACT_NUMBER").Value = CONTACT_No
¤
¤ OdBcOdr = cmd.ExecuteReader(CommandBehavior.SingleResult)
¤
¤ At this point i am getting no result even though there is value in the DB.
¤

Since you're not using a stored procedure I think you need to use the Oracle TO_DATE function in
your SQL statement with a string parameter instead of a date parameter.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Top