cancel
Showing results for 
Search instead for 
Did you mean: 

Removing UserDataSource from a form

Former Member
0 Kudos

I call a UserDataSource like this:


dsQuestions = objForm.DataSources.UserDataSources.Add("Questions", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 254)

Is there anyway to remove "myData" from the form after I'm done with it? I would like to re-use the DataSource, but I get an error that the DataSource already exists when I do.

And yes, I can instantiate another DataSource. I just didn't want my code (and the system resources) to fill up with stuff that I don't need.

Thanks!

PS - releasing dsQuestions using:


System.Runtime.InteropServices.Marshal.ReleaseComObject(dsQuestions)
dsQuestions = Nothing
GC.Collect()

...doesn't work.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Paul,

First u bound the datasource to control

oEdit.DataBind.SetBound(True,"","Questions")

then you reuse it again,

oEdit.DataBind.UnBound()

oEdit1.DataBind.SetBound(True,"","Questions")

Regards,Give me points,

G.Suresh

Former Member
0 Kudos

Thanks,

I'm still having a problem with this though.

I'm binding UserDataSources to columns in a matrix. I know, but this is the only way it will work right now. There's a bug when using DBDataSources with a user table (2007A PL06).

I need to clear and re-use my UserDataSources. Or just kill them and re-instantiate them.

I have tried:


objMatrix.Columns.Item("coQualQ").DataBind.SetBound(False, "", "Questions")

objMatrix.Columns.Item("coQualQ").DataBind.UnBind()

Neither one of these will allow me to reuse the datasource. Once my code comes back to:


 dsQualQues = objForm.DataSources.UserDataSources.Add("Questions", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 254)

...I get error "-2018 - DataSource - Alias Already Exists".

Former Member
0 Kudos

Anyone?

AdKerremans
Active Contributor
0 Kudos

Hi Paul,

you try to add a datasource with the same name twice, this is not possible, but clearing the datasource is just setting the value.

myDataSource.ValueEx="";

Regards

Ad

Former Member
0 Kudos

hi

objForm.DataSources.UserDataSources.Item("Questions").Clear()

Former Member
0 Kudos

Sorry that is for dbdatasource only

Former Member
0 Kudos

Hi Paul,

you can add userdatasource only once to a form, it is just like a hidden item on the form.

once you are done with your business logic with the userdatasource,you reset it to some default value(myDatasource.valueEx="").

you can again use that when needed(myDatasource.valueEx=NewValue).

No need to add it again to the form as long as the form is alive the datasource will be with it.

regards

Vishnu

Answers (1)

Answers (1)

Former Member
0 Kudos

Paul, you can't remove a userdatasource. Instead, try adding it once, on the form_load event, then just use it when you need it or set it to "".

I went through the same issue until I started doing it this way. It's much easier.

Former Member
0 Kudos

Thanks Bryan and Vishnu. That's what I ended up doing after fighting with it for a while.