473,382 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Retrieve MS SQL TYPE TEXT into Dataset

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)
Jul 21 '05 #1
1 1825
Luki wrote:
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)

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.StoredProc edure;
cmd.CommandText="sp_columns";
cmd.Parameters.Add("@table_name", "addresses");

da.SelectCommand=cmd;

da.Fill(dsdb);

this.DataGrid1.DataSource=dsdb;
this.DataGrid1.DataBind();
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: KathyB | last post by:
Sorry this is a bit of a repost because I wasn't quite accurate in my original. I have an hmtl page with a function to see if there are any input type=text boxes. If so, that means a user did...
4
by: Jerry Orr | last post by:
I am attempting to retrieve various MVS dataset allocation parameters (lrecl, block size, etc) from a C/C++ program. The C/C++ Run-time Library Reference states that the function svc99() can be...
1
by: iporter | last post by:
Hi - I am changing a field from type nvarchar to type text, given that I need to store strings longer than 255 characters. To do this I change the data type in SQL Server, then I change the...
12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
1
by: Luki | last post by:
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...
16
by: Mark Rae | last post by:
Hi, Supposing I had a string made up of a person's name followed by their profession in parentheses e.g. string strText = "Tiger Woods (golfer)"; and I wanted to extract the portion of the...
1
by: subbugannamani | last post by:
I want to retrieve the text property of the buttons in another form (for C# desktop application).For ex in Form1.cs I have four buttons I want to get the text property of that 4 buttons in...
1
by: nightwalker | last post by:
hi all, I am trying to retrieve dynamic text value, but I need some helps with my script below. it doesn't get executed. Please help. for (var i =1; i <=3; i++) { ...
2
by: Nilanjan Sanyal | last post by:
how to retrieve hindi text from mysql database using php
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.