473,414 Members | 1,575 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,414 software developers and data experts.

how to put the header for this values

1,anuradha,23000,10,
4,Bhanu Kiran,10000,10,
5,Bhanu Prakash,20000,10,
6,fanendra,33000,20,
7,vamsi,8000,30,
8,joythi,18000,40,
9,naveena,18000,40,
10,ramakrishna,12000,30,
11,ravindra,22000,20,
12,satish,11000,10,
13,lakshmi,30000,20,
14,sudheer,27000,20,
15,Suman Chandra,20000,40,
16,suresh,19000,40,
17,negeswerarao,25000,30,
2,Anuradha,18000,10,
3,arunbabu,10000,20,

this is my .csv file.I got this values from sqlserver but how to get the columnheader from sqlserver please help me.thankq
Aug 7 '07 #1
6 1183
dip_developer
648 Expert 512MB
1,anuradha,23000,10,
4,Bhanu Kiran,10000,10,
5,Bhanu Prakash,20000,10,
6,fanendra,33000,20,
7,vamsi,8000,30,
8,joythi,18000,40,
9,naveena,18000,40,
10,ramakrishna,12000,30,
11,ravindra,22000,20,
12,satish,11000,10,
13,lakshmi,30000,20,
14,sudheer,27000,20,
15,Suman Chandra,20000,40,
16,suresh,19000,40,
17,negeswerarao,25000,30,
2,Anuradha,18000,10,
3,arunbabu,10000,20,

this is my .csv file.I got this values from sqlserver but how to get the columnheader from sqlserver please help me.thankq
Retrieving column names of a table:
In some cases, you need to get the columns of a specific table. There are
basically 3 approaches to do this :

1.Use the sp_help procedure to get extended information about a
database object. By database object, we mean a table, view, and the like (you
can find extended information on this procedure at BOL).

2.You can use the following select statement to retrieve a table’s columns:
SELECT TOP 0 * FROM table_name

3.The third approach, which I personally prefer, is using the schema object of
SQL Server. For example, to retrieve the column names of Authors table, you can
use the following SELECT statement:
SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'authors'

Which results in the following result set:

column_name
----------------------------
au_id
au_lname
au_fname
phone
address
city
state
zip
contract
(9 row(s) affected)
Aug 7 '07 #2
thank u for ur replay
this is my code

StreamWriter writer = File.CreateText(filename);
SqlCommand command1 = new SqlCommand("select top 0 * from mymca", connection);
SqlDataAdapter adapter1 = new SqlDataAdapter(command1);
DataSet ds1=new DataSet();
adapter1.Fill(ds1, "mymca");
DataTable dt1 = ds.Tables["mymca"];
string s2 = ds.Tables["mymca"].Rows[0].ToString();
writer.Write(s2);

how to print the header please help me
Aug 7 '07 #3
ammoos
100 100+
pls try this

StreamWriter writer = File.CreateText(filename);
SqlCommand command1 = new SqlCommand("select * from mymca", connection);
SqlDataAdapter adapter1 = new SqlDataAdapter(command1);
DataSet ds1=new DataSet();
adapter1.Fill(ds1, "mymca");
string s2 = ds.Tables["mymca"].Columns[columnCount].ColumnName;
writer.Write(s2);

in this columnCount is the index of the columns starting from 0

eg:
string s2 = ds.Tables["mymca"].Columns[0].ColumnName;
writer.Write(s2);
string s2 = ds.Tables["mymca"].Columns[1].ColumnName;
writer.Write(s2);
string s2 = ds.Tables["mymca"].Columns[2].ColumnName;
writer.Write(s2);
string s2 = ds.Tables["mymca"].Columns[3].ColumnName;
writer.Write(s2);
Aug 7 '07 #4
thanks for ur replay .i got the answer thank q very much.once again tankq very much have a greate day bye.
Aug 7 '07 #5
Plater
7,872 Expert 4TB
If you have a DataReader (or use a DataAdapter to fill a DataSet/DataTable) all the column names are populated into properties of the object.
Aug 7 '07 #6
thanks plater i got the answer.thanks for your replay.thankq very much.have a greate day bye.
Aug 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Bruce A. Julseth | last post by:
I have a Main.php file the gets data from the user. Main.php then loads Verify.php. Based on the input, Verify.php will load a page. An extract of Verify.php looks like: if($IN = "A") {...
1
by: David Horowitz | last post by:
Hi folks. I need to create a report that has a Group Header that pulls certain data from the Detail section. It's something like this: +--Report---------------------------------------- |...
18
by: John Smith | last post by:
Hi all What does the group think of the practise of including one header file from inside another? I have some legacy code where this has been done, and it creates a dependency on a module...
6
by: Jason Collins | last post by:
There seems to be an inconsistency (bug?) in the way the Set-Cookie header is handled by the WebHeaderCollection. That is, the values of Set-Cookie, when an Expires is specified, contain the ","...
0
by: Evandro Klen S. Azeredo | last post by:
Hi, I'm with the folowing problem: I have two tables: header(id_header) and Itens(id_header, id_item). When I insert data in Itens table, this error is returned: "You cannot add or change a...
2
by: sheldonlg | last post by:
I have used the action= statement to send the form to a new page which can get the posted variables. I have used the header("Location: foo.php) statement after testing on the submit with isset....
8
by: warezguy05 | last post by:
Hi I'd like to forward users to a 'thank-you' page after they've submitted a form. I used this code and it worked perfectly till yesterday; header("Location:...
8
by: fredd00 | last post by:
hi i'm trying to change the gridview columns header text the columns are not auto generated, i have set specific headertext values for each column i want to change the header text based on...
4
by: herbivore | last post by:
I am using curl to do a post request to a server. The request contains xml data, the standard post headers sent by curl do not work. I have tried using the custom_request option with the whole post...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.