field properties aren't there

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

hey all,
I'm doing the following:
SqlCommand mycmd = new SqlCommand(sqlText, conn);
SqlDataAdapter da = new SqlDataAdapter(mycmd);
DataTable tbl = new DataTable();
da.Fill(tbl);

Well, when I check tbl.Columns[x].MaxLength all columns show -1. I checked
and there are columns and I can do tbl.Columns[x].ColumnName. Can someone
please explain?

thanks,
rodchar
 
Hi,

Explain what?

From MSDN:
The maximum length of the column in characters. If the column has no maximum
length, the value is -1 (default).


What were you expecting?
 
Actually, in the database, the field does have a length specified.

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Explain what?

From MSDN:
The maximum length of the column in characters. If the column has no maximum
length, the value is -1 (default).


What were you expecting?

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
rodchar said:
hey all,
I'm doing the following:
SqlCommand mycmd = new SqlCommand(sqlText, conn);
SqlDataAdapter da = new SqlDataAdapter(mycmd);
DataTable tbl = new DataTable();
da.Fill(tbl);

Well, when I check tbl.Columns[x].MaxLength all columns show -1. I checked
and there are columns and I can do tbl.Columns[x].ColumnName. Can someone
please explain?

thanks,
rodchar
 
rodchar said:
Actually, in the database, the field does have a length specified.

Perhaps the database provider code doesn't read those values?
Did you check if the columns/rows contains any data?
 
Hi,


rodchar said:
Actually, in the database, the field does have a length specified.

It might have, but the returned type is string which has no type. I checked
it on a CHAR(10) column and it did return String and MaxLength was -1
 
Back
Top