Databinding Problem solved by renaming table column name???

Posts   
 
    
j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 10-Jul-2014 08:47:03   

Using version 4.2 SelfServing.

If I try to bind this table.

CREATE TABLE [dbo].[ProductionJob]( [Id] [int] IDENTITY(1,1) NOT NULL, [JobId] [int] NULL, .. [MailpiecesNL] [int] NULL, [MailpiecesAbroad] [int] NULL, [MailpiecesReturn] [int] NULL, [MailpiecesPrints] [int] NULL, [IncidentId] varchar NULL, [Remark] varchar NULL, ..

Generation of the ProductionJobEntity will change MailpiecesNL in MailpiecesNl!


if (txtMailpiecesNL.DataBindings.Count == 0) {
        
            txtMailpiecesNL.DataBindings.Add("Text", _bindingSource, ProductionJobFields.MailpiecesNl.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
            txtMailpiecesNL.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);


            txtMailpiecesAbroad.DataBindings.Add("Text", _bindingSource, ProductionJobFields.MailpiecesAbroad.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
            txtMailpiecesAbroad.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

            txtMailpiecesPrints.DataBindings.Add("Text", _bindingSource, ProductionJobFields.MailpiecesPrints.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
            txtMailpiecesPrints.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

            txtMailpiecesReturn.DataBindings.Add("Text", _bindingSource, ProductionJobFields.MailpiecesReturn.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
            txtMailpiecesReturn.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

            txtIncidentId.DataBindings.Add("Text", _bindingSource, ProductionJobFields.IncidentId.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
            txtIncidentId.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

            txtRemark.DataBindings.Add("Text", _bindingSource, ProductionJobFields.Remark.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
         }

Then I can not change or save the value in txtMailpiecesNL.


      private void btnSave_Click(object sender, EventArgs e) {
         _productionJobEntity = (ProductionJobEntity)_bindingSource.Current;
         _productionJobEntity.Save();
      }

If I change in the database

[MailpiecesN**L**] [int] NULL  to   [MailpiecesN**l**] [int] NULL, 

And I generate the ProductionJobEntity again everything works perfect....????

Do I mis something here?

code is working now so it is not urgend. I just want to now if it is a bug or that I have to change settings...

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Jul-2014 17:13:37   

What's the type and version of the database used? Is the schema case sensitive?!

When you say you can't change or save the value, could you please post the generated SQL command?

Also please check the project setting: Relational model data element name casing case sensitive dbs

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 11-Jul-2014 10:30:38   
Frans Bouma | Lead developer LLBLGen Pro
j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 14-Jul-2014 15:01:11   

Thanx for the answers.

I will check the settings you both mention. but first i have to finish this project simple_smile

Bindings etc...


 private void btnSearch_Click(object sender, EventArgs e) {
         _productionJobCollection = new ProductionJobCollection();
         IPredicateExpression iPredicateExpression = new PredicateExpression();

         if (dtpDateTimeSent.Checked) {
            iPredicateExpression.AddWithOr(ProductionJobFields.DateTimeSent > dtpDateTimeSent.Value);
         }
         if (dtpDateTimeStatus.Checked) {
            iPredicateExpression.AddWithOr(ProductionJobFields.DateTimeStatus > dtpDateTimeStatus.Value);
         }
         if (!string.IsNullOrWhiteSpace(txtJobId.Text)) {
            iPredicateExpression.AddWithAnd(ProductionJobFields.JobId == txtJobId.Text);
         }
         if (!string.IsNullOrWhiteSpace(cmbCurrentStatusvalue.Text)) {
            iPredicateExpression.AddWithAnd(ProductionJobFields.CurrentStatusvalue == cmbCurrentStatusvalue.Text);
         }


         _productionJobCollection.GetMulti(iPredicateExpression);
         dgvProductionJobCollection.DataSource = _productionJobCollection;
      }


private void dgvProductionJobCollection_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {

         _productionJobEntity = (ProductionJobEntity)_productionJobCollection[dgvProductionJobCollection.CurrentRow.Index];
         _bindingSource.DataSource = _productionJobEntity;

         BindObjects();

      }

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Jul-2014 15:09:28   

I'll close the thread for now. If you have more info to add or follow up questions for this particular issue, please post a new message in this thread.

Frans Bouma | Lead developer LLBLGen Pro
j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 05-Aug-2014 08:24:02   

I could not find the setting "Relational model data element name casing case sensitive dbs"

But now I had the same problem when using column names like:

OBFMailPiece, int null OBFReturns, int null

when changing these names to:

ObfMailPiece, int null ObfReturns, int null

and the binding:


txtOBFMailpiecesNL.DataBindings.Add("Text", aBindingSource, ProductionJobFields.ObfMailpiecesNl.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesNL.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

txtOBFMailpiecesAbroad.DataBindings.Add("Text", aBindingSource, ProductionJobFields.ObfMailpiecesAbroad.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesAbroad.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

and the method:


txtOBFMailpiecesNL.DataBindings.Add("Text", aBindingSource, ProductionJobFields.ObfMailpiecesNl.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesNL.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

               txtOBFMailpiecesAbroad.DataBindings.Add("Text", aBindingSource, ProductionJobFields.ObfMailpiecesAbroad.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesAbroad.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

Things are working.

when I was debugging I saw(?) things going wrong in the EntityClasses.

What I find strange is that code generation and everything else is going okay. I think even for fields with karakteristics ObfMailPieceName, varchar(20) null.... but if it is an .... INT null column thing go wrong.

I was mailing this (again) because yesterday, after someone changed columns names in DB, I spent 2 hours looking why my code was not working. Duth expression: "een ezel stoot zich geen tweemaal aan dezelfde steen" but I did ;-(

What I would like to know is which settings I have to make so my generated code is always working. Independent of column names used in the DB.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 05-Aug-2014 22:53:24   

May I ask why are you using the SourceColumnName in databinding?

j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 06-Aug-2014 09:01:53   

Because I'm not the DB owner rage and the names are still chancing. In did way I see which names are changed....

Do you know a better option??

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 06-Aug-2014 17:12:33   

Ok, have you checked the settings in the link Otis posted?

j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 06-Aug-2014 21:47:19   

I have read the document but I don't know which settings I have to make to make a column name OBFMailPieces working while if I name it ObfMailPieces it just works confused

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Aug-2014 07:20:39   

LLBLGen Designer makes your entity/field names always PascalCased for default. That's why your OBFMailPieces field name becomes ObfMailPieces. This doesn't affect any functionality on your generated code, except when you assume that the names are not pascal cased.

In your automatically binding code, you assume the name is OBFMailPieces, while the real generated field was named ObfMailPieces (due to the pascal casing rule).

You can change this behavior and tell LLBLGen Designer to left your entity/field names untouched (i.e.: do not apply any pascal casing at all, and left your names are they are in your DB). To do this, do the following: 1. Go to Project->Settings 2. Go to Element Name Construction -> General 3. Mark 'Make element name pascal casing' to false. 4. Click 'Ok'

That will make the PasCal casing stop to do its job whenever you add new elements into your model. For the existing objects in your model you need to change their names manually in LLBLGen Designer. Note that you don't need to change anything in your DB, just do it in your Model in LLBLGen Designer.

I hope that helps wink

David Elizondo | LLBLGen Support Team
j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 11-Aug-2014 11:31:52   

Thanx for the answer. I will try these settings.

I will keep you informed.

No...this is not the solution...disappointed


CREATE TABLE [dbo].[ExampleTable](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [JobId] [int] NULL,
    [StatusHistoryId] [int] NULL,
    [Jobinfo] [varchar](20) NULL,
    [Spoolfile] [varchar](100) NULL,
    [Spoolfile2] [varchar](100) NULL,
    [JobIdCosmosProduction] [int] NULL,
    [JobIdInserter] [int] NULL,
    [JobIdProduction] [int] NULL,
    [InserterSpec] [varchar](100) NULL,
    [InserterStatus] [varchar](100) NULL,
    [JobIdAFPProduction] [varchar](100) NULL,
    [JobToBeDeletedDBP] [bit] NULL,
    [NrEnvelops2Print] [int] NULL,
    [NrPrints] [int] NULL,
    [CurrentStatusvalue] [varchar](100) NULL,
    [DateTimeStatus] [datetime] NULL,
    [MailpiecesInserted] [int] NULL,
    [Mailpieces2Reprint] [int] NULL,
    [ObfMailpiecesNl] [int] NULL,
    [ObfMailpiecesAbroad] [int] NULL,
    [ObfMailpiecesReturned] [int] NULL,
    [OBFPrintsReturned] [int] NULL,
    [OBFMailPiecesError] [int] NULL,
    [OBFIncident] [varchar](20) NULL,
    [OBFRemarks] [varchar](100) NULL,
    [MailpiecesChecked] [bit] NULL,

Will not work!

Strange......

I now use


 private void BasicBindObjects(BindingSource aBindingSource) {
         try {
            if (txtObfRemarks.DataBindings.Count == 0) {
               #region INT
               txtOBFMailpiecesNL.DataBindings.Add("Text", aBindingSource, "ObfMailpiecesNl", false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesNL.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

               txtOBFMailpiecesAbroad.DataBindings.Add("Text", aBindingSource, "ObfMailpiecesAbroad", false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesAbroad.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

               txtOBFMailpiecesReturned.DataBindings.Add("Text", aBindingSource, "ObfMailpiecesReturned", false, DataSourceUpdateMode.OnValidation);
               txtOBFMailpiecesReturned.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

               //txtOBFPrintsReturned.DataBindings.Add("Text", aBindingSource, ProductionJobFields.ObfprintsReturned.SourceColumnName, false, DataSourceUpdateMode.OnValidation);
               txtOBFPrintsReturned.DataBindings.Add("Text", aBindingSource, "OBFPrintsReturned", false, DataSourceUpdateMode.OnValidation);
            
               txtOBFPrintsReturned.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);

               txtOBFMailPiecesError.DataBindings.Add("Text", aBindingSource, "OBFMailPiecesError", false, DataSourceUpdateMode.OnValidation);
               txtOBFMailPiecesError.DataBindings[0].Parse += new ConvertEventHandler(OnExitConTrol);
               #endregion

               #region String
               txtObfIncident.DataBindings.Add("Text", aBindingSource, "OBFIncident", false, DataSourceUpdateMode.OnValidation);
               txtObfRemarks.DataBindings.Add("Text", aBindingSource, "OBFRemarks", false, DataSourceUpdateMode.OnValidation);
               #endregion

            }
         }
         catch (Exception error) {
            MessageBox.Show(error.Message, "Problems BasicBindObjects", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
      }

But it is still not working. frowning

Okay now I have a problem. I try to go back to the old version where everythings works with the same code you see above.

after a rebuild from the SelfService DAL things stop working.

I see in the GUI if i leave a bound textbox which was value 10 and i changed it to 20 when tab(ing) to the next textbox it jumps back to 10....??? The code used to work!

Tips anyone??

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Aug-2014 20:04:39   

I'm having difficulty understanding the nature of the problem.

Could you please provide the simplest possible repro solution with a one table SQL Server schema, so we can trace it down?

Thanks

j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 12-Aug-2014 09:15:21   

Thanx for your response. First I have to complete a project, before my holiday sunglasses , so this can take some weeks. After this I will try to reproduce this problem with a small DB.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 12-Aug-2014 21:42:54   

Ok, I'll close this thread for now and it will be re-opened automatically once you post a reply.