Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / January 2005

Tip: Looking for answers? Try searching our database.

Retrieve MS SQL TYPE TEXT into Dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luki - 31 Jan 2005 16:19 GMT
Hello

i'm stuck on a seemingly small problem. i'm trying get the default value
of a column in a table on a MS SQL Server. i try to use sp_columns. eg
sp_columns @table_name = 'addresses'

in Query Analyzer this will produce a nice list where COLUMN_DEF
contains the default value. but if i fill a dataset with it, the column
COLUMN_DEF is always null! i even binded it to a datagrid and the column
shows up empty.
looking at the SP the column COLUMN_DEF seems to be of type TEXT. so i
guess this is the problem...

any idea on how solve this and get the value in COLUMN_DEF? i would like
to use a system stored procedure, not access the sysobjects directly.

thanks for any pointers!

beat

(i couldn't find any better matching ng. if there's one i'll happily
repost there)
Luki - 31 Jan 2005 16:36 GMT
> Hello
>
[quoted text clipped - 18 lines]
> (i couldn't find any better matching ng. if there's one i'll happily
> repost there)

ok. i just checked this and retrieved a table containing a text field,
the dataset worked perfect. so type TEXT isn't responsible. what the...
here's the code to test:

System.Data.SqlClient.SqlConnection cn=
    new System.Data.SqlClient.SqlConnection(cns);
System.Data.SqlClient.SqlCommand cmd=
    new System.Data.SqlClient.SqlCommand();
System.Data.SqlClient.SqlDataAdapter da=
    new System.Data.SqlClient.SqlDataAdapter();

System.Data.DataSet dsdb=
    new System.Data.DataSet();

cmd.Connection=cn;

cmd.CommandType=System.Data.CommandType.StoredProcedure;
cmd.CommandText="sp_columns";
cmd.Parameters.Add("@table_name", "addresses");

da.SelectCommand=cmd;

da.Fill(dsdb);

this.DataGrid1.DataSource=dsdb;
this.DataGrid1.DataBind();

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.