locked
TreeView has someproblem RRS feed

  • Question

  • User-146269301 posted
    i want to show (1)FirstName + LastName (2)Strokes (3)Videos for my final mca tennis project in treeview i'm struck somewhere logically. THE ERROR IS =============================================================================================== Compiler Error Message: CS0161: '_Default.RunQuery(System.Data.SqlClient.SqlCommand)': not all code paths return a value Source Error: Line 55: } Line 56: Line 57: private DataSet RunQuery(SqlCommand sqlQuery) Line 58: { Line 59: string connectionString = ConfigurationManager.ConnectionStrings["TennisConnectionString ======================================================================================================== I have 2 tables tblLogin UserName,FirstName,LastName,usertype uploadvideo udid,UserName,uploadvideo,stroketype public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e) { if(e.Node.ChildNodes.Count == 0) { switch (e.Node.Depth) { case 0: PopulateUserName(e.Node); break; case 1: PopulateStorkes(e.Node); break; case 2: PopulateVideo(e.Node); break; } } } void PopulateUserName(TreeNode node) { SqlCommand sqlQuery = new SqlCommand("Select UserName,FirstName,LastName,usertype from tblLogin Where usertype='player'"); DataSet resultSet; resultSet = RunQuery(sqlQuery); if (resultSet.Tables.Count > 0) { foreach (DataRow row in resultSet.Tables[0].Rows) { TreeNode NewNode = new TreeNode(row["FirstName"].ToString(), row["LastName"].ToString()); NewNode.PopulateOnDemand = true; NewNode.SelectAction = TreeNodeSelectAction.Expand; node.ChildNodes.Add(NewNode); } } } private DataSet RunQuery(SqlCommand sqlQuery) { string connectionString = ConfigurationManager.ConnectionStrings["TennisConnectionString"].ConnectionString; SqlConnection DBConnection = new SqlConnection(connectionString); SqlDataAdapter dbAdapter = new SqlDataAdapter(); dbAdapter.SelectCommand = sqlQuery; sqlQuery.Connection = DBConnection; DataSet resultsDataset = new DataSet(); try { dbAdapter.Fill(resultsDataset); } catch { labelStatus.Text = "Unable to connect to SQL Server"; } } void PopulateStorkes(TreeNode node) { SqlCommand sqlQuery = new SqlCommand(); sqlQuery.CommandText = "Select stroketype from upload where UserName = @UserName"; sqlQuery.Parameters.Add("@UserName", SqlDbType.Int).Value = node.Value; DataSet resultSet = RunQuery(sqlQuery); if (resultSet.Tables.Count > 0) { foreach (DataRow row in resultSet.Tables[0].Rows) { TreeNode NewNode = new TreeNode(row["stroketype"].ToString()); NewNode.PopulateOnDemand = false; NewNode.SelectAction = TreeNodeSelectAction.None; node.ChildNodes.Add(NewNode); } } } void PopulateVideo(TreeNode node) { SqlCommand sqlQuery = new SqlCommand(); sqlQuery.CommandText = "Select uploadvideo from upload Where UserName = @UserName"; sqlQuery.Parameters.Add("@UserName", SqlDbType.Int).Value = node.Value; DataSet resultSet = RunQuery(sqlQuery); if (resultSet.Tables.Count > 0) { foreach (DataRow row in resultSet.Tables[0].Rows) { TreeNode NewNode = new TreeNode(row["uploadvideo"].ToString()); NewNode.PopulateOnDemand = false; NewNode.SelectAction = TreeNodeSelectAction.None; node.ChildNodes.Add(NewNode); } } } } ------------------------------------------------------------------------------ could anyone help me pls... Thanks-in-Advance. Bharadwaj.B.G
    Monday, November 10, 2008 5:19 AM

Answers

  • User-330204900 posted

    Hi Bharadwaj.B.G, I think your post has gone into the wrong forum you best bet would be to repost to the correct forum say Data Presentation Controls.

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 10, 2008 9:15 AM