本文介绍了显示数据库返回的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试仅将查询中的记录放入页面中.查询从下拉列表中选择要在where子句中使用的值.

SqlConnection sqlCon =新的SqlConnection("Server = FNUEXCPC01 \\ SQLSERVER2005; Database = PREMIUM; Trusted_Connection = yes;");
sqlCon.Open(); SqlCommand sqlCmd =新的SqlCommand();
sqlCmd.Connection = sqlCon;



sqlCmd.CommandText =从RECORDSMG WHERE部门中选择Ref_Link =" + ddview.SelectedValue; //AND School = + ddlistschools.SelectedValue AND Doc_Category = + ddview.SelectedItem;

var结果= sqlCmd.ExecuteReader();
//var myArray = new string [,] {};
while(results.Read())
{

Response.Write(results);
sqlCon.Close();
}


}

Im trying to just dipslay the records from a query in a page.The query select values from the dropdownlist to be used in the where clause.

SqlConnection sqlCon = new SqlConnection("Server=FNUEXCPC01\\SQLSERVER2005;Database=PREMIUM;Trusted_Connection=yes;");
sqlCon.Open(); SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = sqlCon;



sqlCmd.CommandText = "Select Ref_Link from RECORDSMG WHERE Department ="+ddview.SelectedValue; //AND School= + ddlistschools.SelectedValue AND Doc_Category= +ddview.SelectedItem";

var results = sqlCmd.ExecuteReader();
//var myArray = new string[,] { };
while (results.Read())
{

Response.Write(results);
sqlCon.Close();
}


}

推荐答案


这篇关于显示数据库返回的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 12:24