TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gustavo
NA
1.3k
455.3k
Error: DataTable not returning colums.
Mar 22 2010 6:06 PM
Hello:
I am not getting anything back from the DataTable. Can someone tell me what I am missing or if I have something out of order.
public
void
GetFieldList(
string
DBTableName)
{
ClassDB
DBConn =
new
ClassDB
();
//
Connection();
createAdapter();
DBCommand.CommandText =
"SELECT * FROM ["
+ DBTableName.ToString() +
"]"
;
MessageBox
.Show(
"DBCommand.CommandText= "
+ DBCommand.CommandText.ToString());
// Select is good.
DBDataReader = DBCommand.ExecuteReader();
//
DataTable
DBTable =
new
DataTable
();
//
string
DBSQLList =
""
;
//
MessageBox
.Show(
"DBTablename= "
+ DBTableName);
// DBTableName is good.
//
foreach
(
DataColumn
DBColumn
in
DBTable.Columns)
// DOES NOT LOOP THRU COLUMNS <<< ERROR
{
if
(DBSQLList.Length > 0)
{
DBSQLList +=
", "
;
}
DBSQLList += DBColumn.ColumnName;
}
//
MessageBox
.Show(
"DBSQLList= "
+ DBSQLList);
// Its empty.
}
Reply
Answers (
17
)
how to share a procedure between all application parts
Progress Bar in web browser