Click here to Skip to main content
15,886,812 members
Home / Discussions / Database
   

Database

 
GeneralRe: Dynamic Filters Pin
alexrad5-Mar-07 4:36
alexrad5-Mar-07 4:36 
GeneralRe: Dynamic Filters Pin
Sam Heller5-Mar-07 4:37
Sam Heller5-Mar-07 4:37 
GeneralRe: Dynamic Filters Pin
alexrad5-Mar-07 4:41
alexrad5-Mar-07 4:41 
GeneralRe: Dynamic Filters Pin
Pete O'Hanlon5-Mar-07 4:41
mvePete O'Hanlon5-Mar-07 4:41 
GeneralRe: Dynamic Filters Pin
alexrad5-Mar-07 4:43
alexrad5-Mar-07 4:43 
QuestionTrusted connection Pin
alexrad4-Mar-07 14:13
alexrad4-Mar-07 14:13 
AnswerRe: Trusted connection Pin
Mark J. Miller8-Mar-07 6:35
Mark J. Miller8-Mar-07 6:35 
QuestionHow to get the Table Name and Total Row Numbers? [modified] Pin
Khoramdin4-Mar-07 9:57
Khoramdin4-Mar-07 9:57 
Hello everyone,

I am trying to get the list of table in a Database and the total number of rows in each table. I have created the loop which loops and get the Table names. I have problem getting the total number of rows for each table in the Database. I successfully get the Table's name but once it comes to getting the total number of the row, I get problem. I am not sure if I can use the Odbc[0] once again to get the total number of the row since it is in use for the loop to get the Table's name.

My code is:

OdbcCom = new System.Data.Odbc.OdbcCommand("USE " + DataBaseName + ";", OdbcCon);
OdbcDR = OdbcCom.ExecuteReader();
OdbcCom = new System.Data.Odbc.OdbcCommand("SHOW TABLES;", OdbcCon);
OdbcDR = OdbcCom.ExecuteReader();
txtLog.AppendText("Tables inside " + DataBaseName + ":\r\n");
while (OdbcDR.Read())
{
txtLog.AppendText(">> " + OdbcDR[0] + "\r\n");
ListViewItem item1 = new ListViewItem(OdbcDR[0].ToString());

MessageBox.Show("Table name:" + OdbcDR[0].ToString());

// START COUNT
OdbcCom = new System.Data.Odbc.OdbcCommand("SELECT COUNT(*) FROM " + OdbcDR[0].ToString() + ";", OdbcCon);
OdbcDR = OdbcCom.ExecuteReader();

// What should I put to get the return value "Total row number" in here?
item1.SubItems.Add("Need to add the total number of rows here!");
// END COUNT

listView1.Items.Add(item1);
}

Could you be kind enough to help me out on this one? Thank you very much and have a great day.

Khoramdin




-- modified at 16:16 Sunday 4th March, 2007
AnswerRe: How to get the Table Name and Total Row Numbers? Pin
mr_lasseter4-Mar-07 11:11
mr_lasseter4-Mar-07 11:11 
Questionscript DB Pin
Mridang Agarwalla4-Mar-07 4:06
Mridang Agarwalla4-Mar-07 4:06 
AnswerRe: script DB Pin
Harini N K4-Mar-07 19:24
Harini N K4-Mar-07 19:24 
QuestionRemote Server Pin
alexrad4-Mar-07 3:11
alexrad4-Mar-07 3:11 
AnswerRe: Remote Server Pin
Hesham Amin4-Mar-07 4:05
Hesham Amin4-Mar-07 4:05 
AnswerRe: Remote Server Pin
Krish - KP4-Mar-07 21:40
Krish - KP4-Mar-07 21:40 
GeneralRe: Remote Server Pin
alexrad5-Mar-07 1:29
alexrad5-Mar-07 1:29 
QuestionNeed help with tailoring a big sql statement Pin
MasterShin3-Mar-07 11:52
MasterShin3-Mar-07 11:52 
AnswerRe: Need help with tailoring a big sql statement Pin
WoutL3-Mar-07 12:07
WoutL3-Mar-07 12:07 
GeneralRe: Need help with tailoring a big sql statement Pin
MasterShin3-Mar-07 20:50
MasterShin3-Mar-07 20:50 
GeneralRe: Need help with tailoring a big sql statement Pin
WoutL3-Mar-07 22:40
WoutL3-Mar-07 22:40 
QuestionHow should I deal with a table holding my time as Hour, Minute, and Second? Pin
Khoramdin3-Mar-07 5:57
Khoramdin3-Mar-07 5:57 
AnswerRe: How should I deal with a table holding my time as Hour, Minute, and Second? Pin
Hesham Amin3-Mar-07 11:48
Hesham Amin3-Mar-07 11:48 
AnswerRe: How should I deal with a table holding my time as Hour, Minute, and Second? Pin
alexrad4-Mar-07 4:32
alexrad4-Mar-07 4:32 
QuestionSQL COMMAND NOT WORKING Pin
govindkedia3-Mar-07 4:22
govindkedia3-Mar-07 4:22 
AnswerRe: SQL COMMAND NOT WORKING Pin
Hesham Amin3-Mar-07 11:55
Hesham Amin3-Mar-07 11:55 
QuestionHow to find no of slot empty of rack Pin
mohd imran abdul aziz2-Mar-07 23:14
mohd imran abdul aziz2-Mar-07 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.