Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Contributor
3015 Points
601 Posts
Aug 03, 2003 04:50 PM|LINK
int customerIDValue = theCustomerIDYouWantToUse; OleDbCommand oledb = new OleDbCommand(); OleDbConnection connection = new OleDbConnection( "YourConnectionString" ); oledb.CommandType = CommandType.TableDirect; oledb.CommandText = "SELECT Count(*) AS CustomerPurchaseCount FROM purchase_table Where CustomerID=@CustomerID"; OleDbParameter sp1 = oledb.Parameters.Add( new OleDbParameter("@CustomerID",OleDbType.Integer,4 )); sp1.Value = customerIDValue; connection.Open(); int count = (int)oledb.ExecuteScalar(); connection.Close();
McMurdoStati...
Contributor
3015 Points
601 Posts
Re: count the element in a database table
Aug 03, 2003 04:50 PM|LINK
int customerIDValue = theCustomerIDYouWantToUse; OleDbCommand oledb = new OleDbCommand(); OleDbConnection connection = new OleDbConnection( "YourConnectionString" ); oledb.CommandType = CommandType.TableDirect; oledb.CommandText = "SELECT Count(*) AS CustomerPurchaseCount FROM purchase_table Where CustomerID=@CustomerID"; OleDbParameter sp1 = oledb.Parameters.Add( new OleDbParameter("@CustomerID",OleDbType.Integer,4 )); sp1.Value = customerIDValue; connection.Open(); int count = (int)oledb.ExecuteScalar(); connection.Close();