日期:2014-05-17 浏览次数:20835 次
string retVal = ""; string sql = "select wname from tablename where wno='xxx'"; using (SqlConnection conn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = strSql; cmd.CommandType = CommandType.Text; cmd.Connection = conn; conn.Open(); retVal = cmd.ExecuteScalar().ToString(); conn.Close(); } return retVal;