日期:2014-05-17 浏览次数:21009 次
select ta.*,(select top 1 tb.name from D tb where tb.parameterid = 'Status' and tb.parametervalue = ta.status) as dname from A ta大致是这样
string status = "";
string connstr = @"Data Source=.;Initial Catalog=MyDB;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connstr))
{
conn.Open();
using (SqlCommand com = conn.CreateCommand())
{
com.CommandText = "select D.Name as Status from A,D where ParameterID='Status' and A.Status=D.ParameterValue";
DataSet dataset = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(com);
adapter.Fill(dataset);
DataTable dt = dataset.Tables[0];
DataRow row = dt.Rows[0];
status = Convert.ToString(row["Status"]);
}
}
MessageBox.Show(status);