Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column size in a dataset

Status
Not open for further replies.

Coolstep

Programmer
Dec 7, 2004
50
EG
Dear All,

In my application I have 2 database coulmns that include long string values (over 30 characters). When retrieving data from these cells the value returned is truncated to the size of 30 characters only! anyone got an idea about this issue???

 
stsuing,

Here are the steps:
1. I get the value from GUI and insert in DB (Value arrives at the DB without truncation)
2. Query the string values filling a Dataset
3. Refering to the appropriate column in the datatable in the filled dataset, The string retrieved back is truncated to 30 characters only.

I hope it's steps are clear, thank u 4 interest :)
 
what's the definition of the field in the database?

*char*(30) would truncate it for you.

"value arives at db without truncation"

does this mean you can query the value from the database some other way (via sql*plus or analogue) and the 31+ chars are there untouched?

are you using strongly typed datasets?

defining *char*(30) in the xml will truncate it too.


mr s. <;)

 
Mr. S.

sorry 4 late reply

well, the value is untouched in the DB. Querying from DB gets over 30 characters.

About the Dataset, I dunno its type but I don't use the wizard so i'm not sure. It's the default type I guess.

 
you can find the type with the sql command
"desc tablename;" this will tell you all types in the table :)

Age is a consequence of experience
 
Mr. S.

here's how I fill the dataset, after a trial to enlarge the column width:
Code:
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(SqlStmt,conn);
if(this.myDatSet.Tables.Contains(TableName))
        this.myDatSet.Tables[TableName].Clear();
adapter.FillSchema(myDatSet,SchemaType.Source,TableName);
for(x=0;x<myDatSet.Tables[TableName].Columns.Count;x++)
{
        if(myDatSet.Tables[TableName].Columns[x].DataType.ToString().IndexOf("String")>0)
                myDatSet.Tables[TableName].Columns[x].MaxLength=35;
}
int rowCount =adapter.Fill(this.myDatSet,TableName);

but even I can't set the width to more than 30!
 
could .Fill be refreshing the schema?
try this:

Code:
                myDatSet.Tables[TableName].Columns[x].MaxLength=35;
}
MessageBox.Show(this, myDatSet.Tables[TableName].Columns["somestringcolumn"].MaxLength.ToString());
int rowCount =adapter.Fill(this.myDatSet,TableName);
MessageBox.Show(this, myDatSet.Tables[TableName].Columns["somestringcolumn"].MaxLength.ToString());
MessageBox.Show(this, myDatSet.Tables[TableName].Columns["somestringcolumn"].ToString());


mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top