用这个你可得到所有的Column的信息 SELECT a.name as ColumnName, b.name as TypeName, a.Length as TypeLength , a.xprec as Col_Prec, a.xscale as Col_Scale, a.isnullable as 'ISNULL', a.colstat as 'Identity' FROM syscolumns a left join systypes b on b.xtype = a.xtype WHERE a.id = ( select id from sysobjects where name = @DBTableName )
我想能过以下的方法获得长度SqlCommand cmd = new SqlCommand("select 组织名称,书记,组长,数据 from 社区单位支部", sql数据库); SqlDataReader dr=cmd.ExecuteReader(); dr.GetDataTypeName(i);--->获得库中字段的类型我也想用同样的方法获得库中字段的类型长度, to maotin兄: 你的代码我不太理解,能不能再和我说说?非常感谢
SELECT a.name as ColumnName, b.name as TypeName, a.Length as TypeLength , a.xprec as Col_Prec, a.xscale as Col_Scale, a.isnullable as 'ISNULL', a.colstat as 'Identity'
FROM syscolumns a left join systypes b on b.xtype = a.xtype
WHERE a.id = ( select id from sysobjects where name = @DBTableName )
SqlDataReader dr=cmd.ExecuteReader();
dr.GetDataTypeName(i);--->获得库中字段的类型我也想用同样的方法获得库中字段的类型长度,
to maotin兄: 你的代码我不太理解,能不能再和我说说?非常感谢
取视图
DataTable Views = oledbcnn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[] {null, null, null, "VIEW"});