您的位置:程序门 -> .net技术 -> c#



怎样获取一张表里所有字段


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


怎样获取一张表里所有字段[已结贴,结贴人:liujb526]
发表于:2007-03-27 15:48:42 楼主
哪位高手进来指点下啊.
c#中怎样获取一张表里所有字段
发表于:2007-03-27 17:14:041楼 得分:2
using   system.data.sqlclient;  
  sqlconnection   con   =   new   sqlconnection();
    con.connectionstring   =   "persist   security   info=false;initial   catalog=ycqry2;user   id=sa;password=;server= "   +   db.loginserver();
                                                                     
      con.open();
                       
int   year   =   system.datetime.now.year;
                     
                        //不同年对应的用友数据库
                        string   ufdfcode= "select   *   from   ufdfcode   where   cyear= "+year;
                        sqlcommand   cmdufdacode   =   new   sqlcommand(ufdfcode,   con);
                        sqldatareader   drufdfcode   =   cmdufdacode.EXECutereader();

                        string   ufdatabaseold   =   " ";    
                        string   ufdatabasenew   =   " ";
                        while   (drufdfcode.read())
                        {
                                ufdatabaseold=drufdfcode.getstring(1);
                                ufdatabasenew=drufdfcode.getstring(2);
                        }
                        drufdfcode.close();

发表于:2007-03-27 17:15:312楼 得分:2
问题讲明白了吗??
发表于:2007-03-27 17:16:133楼 得分:2
select   *   from   table
发表于:2007-03-27 17:16:424楼 得分:2
select   *   from   table
发表于:2007-03-27 17:18:305楼 得分:2
select           table_catalog   as   [database],   table_schema   as   owner,   table_name   as   tablename,   column_name   as   columnname,     ordinal_position   as   ordinalposition,   column_default   as   defaultsetting,   is_nullable   as   isnullable,   data_type   as   datatype,     character_maximum_length   as   maxlength,   datetime_precision   as   dateprecision,columnproperty(object_id(table_name),   column_name,   'isidentity ')   as   isidentity  
from                   information_schema.columns   where           (table_name   =   '表名 ')
发表于:2007-03-27 17:22:406楼 得分:2
select   tablecolumns.name   columnname
from   sysobjects   tables,   syscolumns   tablecolumns
where   tables.id   =   tablecolumns.id  
and   tables.name   =   '表名 '
发表于:2007-03-27 17:23:087楼 得分:2
select   name   from   syscolumns   where   id=object_id( 'table ')
发表于:2007-03-27 17:56:298楼 得分:2
up
大家的都是sql语句
楼主是想问c#这样连接数据库吧!
发表于:2007-03-27 20:35:089楼 得分:4
推荐   popeye627(一曲肝肠断,天涯何处觅知音?)     的
     
select   name   from   syscolumns   where   id=object_id( 'table ')
发表于:2007-03-28 18:45:2710楼 得分:0
呵呵
jinwmmail这位大哥才是我想要的。


快速检索

最新资讯
热门点击