cancel
Showing results for 
Search instead for 
Did you mean: 

Query problem

Former Member
0 Kudos

im trying to make a sample filtr on B1 table OHEM

Me.title is a param with the Date which interesed me. when Me.title ( String ) = "19980704" or = "1998/07/04"

and in myTable (Matrix of DBDataSource datas )i have one position with this value, im getting and exception error

(0xFFFFFFFFF): Exception from HRESUTL: 0xFFFFFFFFF. at ... Query(Conditions Conds). in the debag. cond.CondVal ="1998-07-04 00:00:00" so it was formated correctly !!

here is a part of the code:

conds = New SAPbouiCOM.Conditions

If (Me.title <> "") Then

cond = conds.Add

cond.BracketOpenNum = 1

cond.Alias = "startDate"

cond.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

sDate = CDate(Me.title)

cond.CondVal=sDate.ToString

cond.BracketCloseNum = 1

End If

myTable.Clear()

myTable.AutoResizeColumns()

Try

myData.Query(conds)

Catch ex As Exception

SBO_Application.MessageBox(" query error " + ex.ToString)

End Try

Any answer could be very helpful !! Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

im not reciving any error it just crashed, even under the debuger i cannt see any thing it just stop on oEmp.StartDate = text.ToString, then i need to close every thing !!!

could you please show me some of your code where you update the date to the DB ?

Thanks

Former Member
0 Kudos

Hey Amir.

Do u have a try catch block around that line? Does it throw any exceptions? Can you try hardcoding a date in the same format? I am not sure if you need to use this format when setting the object data directly or if you have to actually use a date object. Can you try setting it to the system date

Former Member
0 Kudos

Hi,

im still have a problem with this date format.

Now the filtre is working but when im trying to update the date field in my Matrix which show the results

oEmp = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oEmployeesInfo)

oEmp.GetByKey(myData.GetValue("empID", lineNr))

oEmp.FirstName = myData.GetValue("firstName", lineNr)

oEmp.LastName = myData.GetValue("lastName", lineNr)

text = myData.GetValue("startDate", lineNr)

oEmp.StartDate = text.ToString

If oEmp.Update() <> 0 Then

MsgBox(SBO_Company.GetLastErrorDescription)

End If

Next lineNr

Updateing the firstName and lastName field works fine but the date crash and the application stop to work!!. The "text" gives me ( "19980102" format ) so it should be accepted by the database!!!!.

have you any infos to share with me about this issue??

Thanks

Former Member
0 Kudos

Hey Amir.

What error message do you receive? We have also experience issues with setting the date type on a matrix field.

The problem we had occured when the month or day value was a single digit. We always had to add 0 in front of it for the date to get set.

Ex: 200511 was not accepted but 20050101 worked

former_member185703
Active Contributor
0 Kudos

Amir,

You should not convert the date with CDate when working with a condition (I guess you will have found out in the meantime by yourself...):

From these statements only c) "DB format" works.

a) sDate = CDate("2002/05/01") ' US format

b) sDate = CDate("01.05.2002") ' common format in Mid-Europe

c) sDate = "20020501" ' "DB format"

cond.CondVal = sDate.ToString

...

Regards,

Frank