数据库访问引擎已写好,下面是执行sql语句的
public DataTable GetDataTable(string argSqlString)
{
SqlCommand sqlSelectCommand = new SqlCommand(argSqlString, dbConnection);
sqlSelectCommand.CommandTimeout = 300;
if (dbTrans != null)
sqlSelectCommand.Transaction = dbTrans;
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlSelectCommand);
DataTable dataTable = new DataTable();
sqlDataAdapter.Fill(dataTable);///通过数据适配器对象的fill方法填充数据集,且返回一个数据库表;
return dataTable;
}新建了一个窗体,包含一个文本框和一个button,在文本框里写如查询语句如select * from data,然后点击按钮,我想测试能不能查询出来,应该怎么写啊??
private void select_Click(object sender, EventArgs e)
{
//怎么写啊
}
public DataTable GetDataTable(string argSqlString)
{
SqlCommand sqlSelectCommand = new SqlCommand(argSqlString, dbConnection);
sqlSelectCommand.CommandTimeout = 300;
if (dbTrans != null)
sqlSelectCommand.Transaction = dbTrans;
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlSelectCommand);
DataTable dataTable = new DataTable();
sqlDataAdapter.Fill(dataTable);///通过数据适配器对象的fill方法填充数据集,且返回一个数据库表;
return dataTable;
}新建了一个窗体,包含一个文本框和一个button,在文本框里写如查询语句如select * from data,然后点击按钮,我想测试能不能查询出来,应该怎么写啊??
private void select_Click(object sender, EventArgs e)
{
//怎么写啊
}
解决方案 »
- 如何从html中提取需要的数据.-2
- 求教,string 不包含text???这是什么原因求解
- 请大家推荐一款C/S模式下使用的报表控件吧
- WinForm如何将光标定位在DataGridView的某个单元格上
- *********怎么实现把SQLSERVER数据库数据导出到excel***********
- treeView 新建节点问题
- C#中怎样使用指针???????
- SQL2005表中数据导出到Access2007里的问题
- 局域网内怎样通过IP获取其他机器的进程???
- 通过winform删除本地硬盘上的文件
- 窗体button点击问题
- 通过Process.Start("mytest.exe","1")给mytest.exe传递参数1 ,要怎么写mytest.exe里面的代码?
然后你赋给什么数据控件啥的
{
try
{
DataTable _Table =GetDataTable(textBox1.Text);
MessageBox.Show("结果"+_Table.Rows.Count.ToString()+!");}
catch
{
MessageBox.Show("查不出来!");
}
}