-
April 20th, 2013, 04:12 PM
#1
[RESOLVED] Column pulling of a database
Ok. I've been working on this project for a while and I've looked everywhere from stackoverflow to MSDN for a way to pull columns from a database. I want to format each column to a prefixed length. Any way that I can be able to call the columns of a DataTable to a individual variables as to call them by their variable name? If so, how would this be done? I'm completely new and I've been learning C# on my own. Please help???? Here is relevant code:
string query = "SELECT * FROM CJIS_JAIL_PARTIES";
SqlConnection connString = new SqlConnection(connectionString);
//Run query
SqlCommand execution = new SqlCommand(query, connString);
//Execute the SQL DataReader
SqlDataReader executionReader = execution.ExecuteReader();
//Create DataTable to hold data returned from query
DataTable dataTable = new DataTable();
//Create DataTable.Load(SqlDataReader) to put the results of the query into a DataTable
dataTable.Load(executionReader);
-
April 20th, 2013, 04:25 PM
#2
Re: Column pulling of a database
Save it, or export/import it is one way
-
April 20th, 2013, 04:27 PM
#3
Re: Column pulling of a database
Originally Posted by dglienna
Save it, or export/import it is one way
I'm not looking to export/import because I'm trying to write it to a preformatted file.
-
April 20th, 2013, 09:32 PM
#4
Re: Column pulling of a database
What format is returned? Probably loses the formatting...
-
April 22nd, 2013, 07:31 AM
#5
Re: Column pulling of a database
What do you do with the datatable? Does it have to be in a data table? If not, create an entity class that mimics the database table, and use a reader to populate the class. Create a collection, or list of your entity class for the rows. Then you can call the variables anything you want.
-
April 22nd, 2013, 07:41 AM
#6
Re: Column pulling of a database
Thank you. That helps a lot I'm know most basic and some advanced stuff. This is what I was looking for. Thank you
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|