質問

"AVAILABLEDATE" is a column of type DATE.

I can query the table via Toad and get results. However, in (Winforms/C#/dotConnect) code, it's not working.

ocmd.Parameters.Add("AVAIL_DATE", getDateToQuery());

I'm pretty sure the problem is the way I'm passing the date:

private DateTime getDateToQuery() {
  DateTime candidateVal = dateTimePickerScheduleDate.Value;
  if (candidateVal.Equals(null)) {
    candidateVal = DateTime.Now;
  }
  return candidateVal;
}

...but I don't know how to force the date value to be in the format Oracle will recognize.

役に立ちましたか?

解決 2

This works, but I'm not sure it's the best way:

int iFromYear = dateTimePickerScheduleDate.Value.Year;
int iFromMonth = dateTimePickerScheduleDate.Value.Month;
int iFromDay = dateTimePickerScheduleDate.Value.Day;
. . .
ocmd.Parameters.Add("AVAIL_DATE", new DateTime(iFromYear, iFromMonth, iFromDay));

他のヒント

Try adding the parameter type:

OracleParameter p1 = new OracleParameter("AVAIL_DATE", OracleDbType.Date);
p1.Value = getDateToQuery();
ocmd.Parameters.Add(p1);

Also, make sure you provide the parameters in order, the last time I worked with Oracle I remember the names of the parameters were ignored.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top