Thanks yes I worked it out. It was just a silly curly brace. i wasn't missing one as such, I just had to move them around. Wasn't worth the question. Sorry about that.
falles01
Posts
-
Simple question about ending loops -
Simple question about ending loopsI have a problem where I've got a large amount of nested if statements. they were all working and executing the correct numbe of times until I added some loops at the start. The debugger is showing that it executes the first section and then starts again without going to the next condition. I know I have to change the condition maybe. This is the first section that gets executed continuously. Obviously there will always be rows, but the rest of conditions say, if checkedbox is ticked, or combobox is selected bla bla, so I can't see why (if I select a combobox item and click search, it is not executing). Is there a way of telling the code that you want to end the loop after all the entries in the database have been covered? Make sense?
foreach (DataRow row in dsapps.Tables[0].Rows) { if (row["EmployeeID"].ToString().Equals(EmployeeID.ToString()) == false) { if (EmployeeID > 0)
-
concatenating strings into one datagrid cellI got a response from the sql forum but I worked it out myself. Let me know if you want my answer. I have another simple question but I will post a new message. :)
-
concatenating strings into one datagrid cellHello if anyone can please give me just a tiny sample of how I'd do this, not just what to do I will be so grateful. Just so you know. I have been googling for days on this and I'm not sure what to do as I am still pretty new to c#. This is what I want to do. I have a dataset and datagrid(search results table) displaying results like this. Siann Skills1 Siann Skills2 Siann Skills3 I want it to show this Siann Skills1,Skills2,Skills3. I have my select statement, then I have created a new datacolumn as I was told to do as below. Now after that, what do I do? How do I get all the skills in one column. I know I have to concatenate, and I have tried searching the net, but I can't find anything useful. is there any possibility for an example? dgSearchResults.Columns.Add(new DataColumn("skills", GetType())); I then have my foreach. I need to put something in the foreach. foreach (DataSet1.EmpSkillsRow empskillsRow in empskillsDT.Rows) { } I was told on the C# forum to try here. I am not using sql 2005 so I can't use cte.
-
concatenating strings into one datagrid celloh I thought I had 2005 but I was just told that the back end is still 2000. So is there any other option? Sorry. :(
-
concatenating strings into one datagrid cellThanks that looks really useful. I'll try it out. (will prob take me a while to convert it into what i need) but I'll let you know how I go. :)
-
concatenating strings into one datagrid cellThanks but apparently I can't for some reason. I think I need a for each statement. It is just I don't know exactly what to put in there. I have foreach (DataSet1.EmpSkillsRow empskillsRow in empskillsDT.Rows) { } Apparently then I have to create an empty string and then another text string and then for each loop fill the particular cell. Basically every time a TechnicalSkillID belongs to the same EmployeeID, then display in the TechnicalSkills column in one cell. No one seems to know how this is done in C#. We all know what to do but not how exactly. Do you know? thanks kindly really.
-
concatenating strings into one datagrid cellHello if anyone can please give me just a tiny sample of how I'd do this, not just what to do I will be so grateful. Just so you know. I have been googling for days on this and I'm not sure what to do as I am still pretty new to c#. This is what I want to do. I have a dataset and datagrid(search results table) displaying results like this. Siann Skills1 Siann Skills2 Siann Skills3 I want it to show this Siann Skills1,Skills2,Skills3. I have my select statement, then I have created a new datacolumn as I was told to do as below. Now after that, what do I do? How do I get all the skills in one column. I know I have to concatenate, and I have tried searching the net, but I can't find anything useful. is there any possibility for an example? dgSearchResults.Columns.Add(new DataColumn("skills", GetType())); :)
-
Multiple entries per row in a datagridSorry but I'll give you my code so oyu can see what I currently do.
string sql = "bla bla "; SqlDataAdapter myCommand = new SqlDataAdapter(sql, myConnection); //Create dataset and fill it with employee data DataSet ds = new DataSet(); myCommand.Fill(ds); //bind employee data to datagrid DataView Source = ds.Tables[0].DefaultView; Source.Sort = sortField; dgSearchResults.DataSource = ds.Tables[0];
After this would I then create a new datacolumn? I found this link. Is it something like that? and then I have to concatenate string somehow? :) http://msdn2.microsoft.com/en-US/library/system.data.datacolumn.aspx">http://msdn2.microsoft.com/en-US/library/system.data.datacolumn.aspx -
Multiple entries per row in a datagridThanks. I never ask a question on a forum unless I hae thoroughly searched google and haven't found anything or I don't know what I'm searching for, hence the question. In regards to your tip, I already have a skills column which works fine but just displays each new skills in a new row. Do you mean create another column for skills?
-
Multiple entries per row in a datagridYou mean concatenate the skills into one field using sql? How do you do that? My sql statement gets all the correct skills but how do you get it into one field? wouldn't I need some c# code for that?
-
Multiple entries per row in a datagridAdelaide. Not really close to brisbane at all. The opposite side of Australia actually.
-
Multiple entries per row in a datagridThanks. That could work but they can have up to 20 skills. Is there a way to get maybe a drop down box with results or all results in one field?:)
-
Multiple entries per row in a datagridHi there. I have had a search on the net but can't find anything that matches what i need. I have a datagrid which I have displaying entries from a dataset. What thw problem is, is that the same person displays multiple times depending on how many skills they have. EG Tom Hanks Skill1 Tom Hanks Skill2 bla bla I want the skills to display in one row. EG Tom Hanks Skill1, Skill2, Skill3 etc. I found something on the code project but it doesn't seem relevant. I think I have my sql select statement correct but I'm thinking I'll need some sort of loop? Thank you
-
Concatenating Sql queriesThankyou. I need to have nested loops because I've got multiple user search options on a windows form. I have it working baced on what I said. I just had to do a bit more trial and error and I would've worked it out without asking. Thank you :)
-
Concatenating Sql queriesah...i think I worked it out now. I'm not sure if that is what you were trying to tell me anyway, but I have declared the common query outside all the loops like this string sql = "Select e.Firstname,e.Lastname,r.Role,r.Description,d.DivisionName,a.Applications,m.ManagerFirstname,m.ManagerLastname,t.ProgLanguagesDatabase" + " from employees e,Role r,Division d, Manager m, TechnicalSkills t,Applications"; then later i have used sql2 = sql + "where etc"; Is this the correct way? thanks Sharny
-
Concatenating Sql queriesif I declare them outside the loops string sql1; string sql2; string sql3; etc then inside each for loop I have a sql query like for () { sql2 = sql1 + "where bla bla"; } for() { sql3 = sql1 +"where bla bla"; } Obviously sql1 and 2 and 3 etc are never assigned as they are defined outside the loops and it never picks up their value? This is what the error is telling me anyway. Thanks
-
Concatenating Sql queriesHi, I have a long SQL querie and my TL has asked that I concatenate them so I am not repeating the same querie over and over again. The thing is, each querie is inside a new for loop so if I concatenate, it is not picking up the previous query. For example this is what I had before for each for loop except that the end where clause is different for each.
for bla bla { ring sql = "select e.Firstname,e.Lastname,r.Role,r.Description,d.DivisionName,a.Applications,m.ManagerFirstname,m.ManagerLastname,t.ProgLanguagesDatabase" + " from employees e,Division d,Manager m,TechnicalSkills t,Role r,Applications a where " + " e.ManagerID = m.ManagerID
My TL wants me to write for { sql1 = blabla } for bla { sql2 = sql1 + (Sql query) } Obviously it is telling me that sql2 does not exist. At the moment I have something like this after the queries. SqlDataAdapter myCommand = new SqlDataAdapter(sql, myConnection); and obviously I can't overload this each time with sql2, sql3 etc)??? Sianny aka Sharny -
Help with class Diagram methodsHI, I am wondering what to include for the method part of a class diagram. I have already created my program and I'm going back to this to correct it. I know you usually have get and set methods but my TL told me to include what ever my code says, but I use sql statements to get the data and then display them using table adapters using .FILL.Can anyone help me out? ;);) Sianny aka Sharny
-
Question on checkedlistbox if statementHi all, for those of you who have been reading my countless posts on this same question, I think I have solved the problem by binding the database data to the checkedlistbox by using datasource and valuemember properties instead of the other way I was doing it because now the checkedlistbox items now bind by ID. Now in order to make the boxes auto tick depending on the particular employee page I am in(eg.this.EmployeeID), I think all I need help on is this 'if' statement. so far all the boxes are ticking with the following code. What is the if statement going to be?
techSkillsCheckListBox2.DataSource = dataSet1.TechnicalSkills; techSkillsCheckListBox2.DisplayMember = "ProgLanguagesDatabase"; techSkillsCheckListBox2.ValueMember = "TechnicalSkillsID"; int i; for (i = 0; i <= (techSkillsCheckListBox2.Items.Count - 1); i++) { if (FirstnameText.Text.Equals(this.EmployeeID)) { sql = "Select em.TechnicalSkillsID,t.TechnicalSkills,em.EmployeeID from EmpSkills em, TechnicalSkills t where t.TechnicalSkillsID = em.TechnicalSkillsID and em.EmployeeID = '" + FirstnameText.Text + "'"; techSkillsCheckListBox2.SetItemChecked(i, true)
Thank you :^) Sianny aka Sharny