[dba-VB] Update gets string or binary truncation error

William Hindman wdhindman at dejpolsystems.com
Tue Apr 29 10:26:31 CDT 2008


...sigh ...I look at some of the stuff Shamil posts and haven't a clue what 
he's doing, much less why ...waaaaaaaay over my head ...so much so I get a 
bad headache every time I try to read some of it ...but you definitely get 
an AMEN! ...and then some ...on VS2K8 ...when MS finally gets something 
right, its RIGHT!!! :)

William

--------------------------------------------------
From: "Gustav Brock" <Gustav at cactus.dk>
Sent: Tuesday, April 29, 2008 10:39 AM
To: <dba-vb at databaseadvisors.com>
Subject: Re: [dba-VB] Update gets string or binary truncation error

> Hi John
>
> That is what the DataTableAdapter is for. If you use the wizard for 
> creating these to attach your tables, it will do all the plumbing and 
> create a (giant) class which wraps all this for you taking care of 
> relations, not null, max lengths, strong types, error handling etc. etc. 
> not to say provide the basis for creating all the queries you need 
> including ready-made basic queries for CRUD as well as giving you the 
> choice to use stored procedures, pass-through or normal queries.
>
> All of this is controlled from a graphic layout like a relations view. If 
> that isn't enough it also lets you carry on with Data Access Layers and 
> business rules.
>
> Nothing is hidden or secret. You can browse the class should you have the 
> patience and wish so. This is a snippet:
>
>            private void InitClass() {
>                this.columnKundeNr = new 
> global::System.Data.DataColumn("KundeNr", typeof(int), null, 
> global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnKundeNr);
>                this.columnNavn = new 
> global::System.Data.DataColumn("Navn", typeof(string), null, 
> global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnNavn);
>                this.columnAdr1 = new 
> global::System.Data.DataColumn("Adr1", typeof(string), null, 
> global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnAdr1);
>                this.columnAdr2 = new 
> global::System.Data.DataColumn("Adr2", typeof(string), null, 
> global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnAdr2);
>                this.columnPostNr = new 
> global::System.Data.DataColumn("PostNr", typeof(string), null, 
> global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnPostNr);
>                this.columnBynavn = new 
> global::System.Data.DataColumn("Bynavn", typeof(string), null, 
> global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnBynavn);
>                this.columnTlf = new global::System.Data.DataColumn("Tlf", 
> typeof(string), null, global::System.Data.MappingType.Element);
>                base.Columns.Add(this.columnTlf);
>                this.Constraints.Add(new 
> global::System.Data.UniqueConstraint("Constraint1", new 
> global::System.Data.DataColumn[] {
>                                this.columnKundeNr}, true));
>                this.columnKundeNr.AllowDBNull = false;
>                this.columnKundeNr.Unique = true;
>                this.columnNavn.AllowDBNull = false;
>                this.columnNavn.MaxLength = 50;
>                this.columnAdr1.MaxLength = 50;
>                this.columnAdr2.MaxLength = 50;
>                this.columnPostNr.MaxLength = 50;
>                this.columnBynavn.MaxLength = 50;
>                this.columnTlf.MaxLength = 50;
>            }
>
> If you redesign the table structure from within Visual Studio, it will 
> track the changes and adjust the class accordingly.
>
> It is  __so clever__  that I wonder why most are still moving on with SQL 
> builders, hand built command strings and the like - pure waste of time in 
> my opinion - except for programmers with special needs and knowledge like 
> Shamil who knows what he is doing.
>
> William, I think, will amen this.
>
> I must admit that because of VS2008 I'm ready to forgive MS much of their 
> bad doings.
>
> /gustav
>
>>>> jwcolby at colbyconsulting.com 29-04-2008 15:53 >>>
> I am doing the update thing, updating data back to SQL Server.  I have
> been updating an ADO recordset in memory and when I try to update it
> back to SQL Server it throws an error that the update failed because it
> would cause a string value to be truncated.
>
> How is this possible.  I thought that the table structure in memory
> mirrored the structure in the data store (SQL Server in this instance).
>  Doesn't the read of the data out of SQL Service discover the field
> size and type and build a similar structure in memory?
>
> Apparently not, but if not how do I handle a case like this?
> -- 
> John W. Colby
> www.ColbyConsulting.com
>
>
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
>
> 





More information about the dba-VB mailing list