I am trying to get the record count to use for my progress bar. I am using the code below to optain the record count on a SQL Server table. Is this correct? on the alert below...it returns a "undefined" msg.
var RowCount
var db3
// Create our connection to SQL server.
db3 = new DbConnection("mssql://" + textbox.getText() + ":1434/" + selected_items2[i]);
// Get the Row count for our table to use in the Progressbar
RowCount = db3.execute("Select Count(*) As Cnt From [" + selected_items[x] + "]");
alert(RowCount.Cnt);
Kirix Support Forums
Get Record count
4 posts
• Page 1 of 1
Re: Get Record count
The execute() function returns a result set. Before accessing a field in the result set, you have to get the first row:
- Code: Select all
// select the rows and display the values
var result = db.execute("SELECT * FROM mytable");
// get the first row
result.next();
// get the field
var rowcount = result.rowcount;
Aaron Williams
Kirix Support Team
Kirix Support Team
-
Aaron - Kirix Support Team
- Posts: 120
- Joined: Fri Dec 16, 2005 3:01 pm
Re: Get Record count
Still the same error. This is what i changed it to. I added another alert to see if my table name was coming up right in my variable and it is.
// Create our connection to SQL server.
db3 = new DbConnection("mssql://" + textbox.getText() + ":1434/" + selected_items2[i]);
// Get the Row count for our table to use in the Progressbar
RecCount = db3.execute("Select * From [" + selected_items[x] + "]");
RecCount.next();
var rows = RecCount.rowcount;
alert(selected_items[x]);
alert(rows);
// Create our connection to SQL server.
db3 = new DbConnection("mssql://" + textbox.getText() + ":1434/" + selected_items2[i]);
// Get the Row count for our table to use in the Progressbar
RecCount = db3.execute("Select * From [" + selected_items[x] + "]");
RecCount.next();
var rows = RecCount.rowcount;
alert(selected_items[x]);
alert(rows);
- abenitez77
- Registered User
- Posts: 143
- Joined: Fri Jan 21, 2011 12:42 pm
Re: Get Record count
My bad... I fixed it...here is what it should have been:
// Get the Row count for our table to use in the Progressbar
RecCount = db3.execute("Select Count(*) as Cnt From [" + selected_items[x] + "]");
RecCount.next();
var rows = RecCount.Cnt;
alert(selected_items[x]);
alert(rows);
// Get the Row count for our table to use in the Progressbar
RecCount = db3.execute("Select Count(*) as Cnt From [" + selected_items[x] + "]");
RecCount.next();
var rows = RecCount.Cnt;
alert(selected_items[x]);
alert(rows);
- abenitez77
- Registered User
- Posts: 143
- Joined: Fri Jan 21, 2011 12:42 pm
4 posts
· Page 1 of 1
Return to Strata Help & Feedback