string connectionString = "Data Source=192.168.1.3;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False";
string queryString = "select dbms_xplan from table where .....";//加上查询条件,
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
richtextbox.Text = reader[0].ToString().Trim();
}
}
finally
{
command.Dispose();
connection.Close(); }
}
解决方案 »
- 基于角色的权限设计 - 数据库
- winform中textbox对鼠标滚轮的响应问题
- 新手问C#访问数据库问题,这个问题对你们来说应该非常简单,见笑了!![
- 我在C#拿到IE得属性
- 请问能否防止WINDOWS的后台服务程序在管理工具的服务中被停止,暂停或者删除
- 急! tabcontrol 控件的 TabIndexChanged 事件
- combobox
- c#.DataGridview
- 请问,在一个线程连接socket中,如果同时调用send方法,能否将一条条完整的消息发送
- 大数据处理思路---大神们求给思路
- Repeater多列分别合并单元格自动序号问题???
- 各位帅哥大神们,请问C#解决方案的修改时间可以更改吗?
string queryString = "select dbms_xplan from table where .....";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
StringBuilder sb = new StringBuilder();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
sb.Append(reader[0] != DBNull.Value ?reader[0].ToString().Trim() : String.Empty);
}
}
richtextbox.Text = sb.ToString();
}SqlDataReader用完需要Close,或者使用using表达式。
用select * from table(dbms_xplan.display(......));
我想把上面结果显示在richtextbox里,由于上面的结果不是一列一列存放的,
所以无法将结果存放到datagridview,这里用的是* 号,二楼的方法我明天试一下,谢谢。