Advertisement
Advertisement
| 05.08.2008 at 08:51AM PDT, ID: 23386526 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: |
public static DataSet dbValueGet() {
DataSet ds = new DataSet();
string connection = ConfigurationManager.ConnectionStrings["LocalConnection"].ConnectionString;
SqlConnection con = new SqlConnection(connection);
string sql = "SELECT * FROM Tags; SELECT * FROM TagLanguage";
//Query tables and add to Dataset.
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter daTagLanguage = new SqlDataAdapter(cmd);
daTagLanguage.Fill(ds);
return ds;
}
THIS IS THE METHOD THAT FAILES
public static string cacheValueGet(string tagname, out bool isDefined) {
string rtnStr = "Undefined";
isDefined = false;
DataSet ds = null;
if (ds == null) {
ds = db.dbValueGet();
//table index 1 = [dbo.Tags]
//table index 0 = [dbo.TagLanguage]
//Set tags Primary Key
DataTable dtTags = ds.Tables[0];
DataColumn[] dcTagsPrimary = { dtTags.Columns["id"] };
dtTags.PrimaryKey = dcTagsPrimary;
//Set tags Primary Key
DataTable dtTagLangs = ds.Tables[1];
DataColumn[] dcTagsLangsPrimary = { dtTagLangs.Columns["TagID"], dtTagLangs.Columns["LangID"] };
dtTagLangs.PrimaryKey = dcTagsLangsPrimary;
//Set up the dataset Relationship
DataColumn[] dcTagsForeign = new DataColumn[] { ds.Tables[0].Columns["id"] };
DataColumn[] dcTagsLangsForeign = new DataColumn[] { ds.Tables[1].Columns["TagID"] };
DataRelation TagsLangs_Tags = new DataRelation("TagLangRelationship", dcTagsForeign, dcTagsLangsForeign);
ds.Relations.Add(TagsLangs_Tags);
//Add the dataset into cache
}
DataRow drFiltered = ds.Tables[0].Rows.Find(tagname);
if (drFiltered != null) {
//then you know you have the records filtered.
return drFiltered[0].ToString();
}
else {
isDefined = false;
}
return rtnStr;
}
|