计算数据集与c ++ 2008中的记录数 [英] Count number of records in a dataset vs c++ 2008
本文介绍了计算数据集与c ++ 2008中的记录数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我在计算数据集中的行数时遇到问题我连接到数据库
String ^ constring = L datasource = localhost; port = 3306; username = root; password = kocurka12;
MySqlConnection ^ conDataBase = gcnew MySqlConnection(constring);
MySqlCommand ^ cmdDataBase = gcnew MySqlCommand( select * from database.new_table where model =' + this-> Search-> Text + ',conDataBase);
尝试 {
MySqlDataAdapter ^ sda = gcnew MySqlDataAdapter();
sda-> SelectCommand = cmdDataBase;
DataTable ^ dbDataSet = gcnew DataTable();
sda-> Fill(dbDataSet);
BindingSource ^ bSource = gcnew BindingSource();
bSource-> DataSource = dbDataSet;
dataGridView1-> DataSource = bSource;
sda->更新(dbDataSet);
} catch (Exception ^ ex){
MessageBox :: Show(ex-> Message);
}
}
现在我想使用dbDataSt.Tables(new_Table)在数据集中拉出行数.Rows.Count;由于某种原因总是有些问题总是有用吗?
解决方案
SELECT COUNT(*)FROM database.new_table其中MODEL = ...
hello all I have got problem with counting row in dataset I have connected to database
String^ constring=L"datasource=localhost;port=3306;username=root;password=kocurka12";
MySqlConnection^ conDataBase=gcnew MySqlConnection(constring);
MySqlCommand^ cmdDataBase=gcnew MySqlCommand("select * from database.new_table where model ='"+this->Search->Text+"' ",conDataBase);
try{
MySqlDataAdapter^ sda=gcnew MySqlDataAdapter();
sda->SelectCommand=cmdDataBase;
DataTable^ dbDataSet= gcnew DataTable();
sda->Fill(dbDataSet);
BindingSource^ bSource = gcnew BindingSource();
bSource->DataSource=dbDataSet;
dataGridView1->DataSource =bSource;
sda->Update(dbDataSet);
} catch(Exception^ ex){
MessageBox::Show(ex->Message);
}
}
now I Would like to pull numbers of rows in dataset unfortunately using dbDataSt.Tables("new_Table").Rows.Count; does not work for some reason always some problems any one would help??
解决方案
SELECT COUNT(*) FROM database.new_table where MODEL= ...
这篇关于计算数据集与c ++ 2008中的记录数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文