Add checkboxs dynamically in csharp smart device project
-
Hello, I am developing a GMAO csharp smart device application.I am in the step of adding checkboxs dynamically:
I have two tables:Travaux (Works in English) and Actions related by the two fields Nature (table Travaux)and typeTravail(Table Actions).If the user enters the number of the work(NBT the pk_Travaux),the system adds a number of checkboxs equal to the steps that should the user follows to accomplish(field step in Actions table).After that,the user has the possibility to check or not the step if he did it.All the traitments will be done dynamically with the database
My select statement is:
select Etape from Action where ((Travaux.NBT=textbox1.text) and (Travaux.Nature=Action.TypeTravail))
Equal of what this select returns,it will add dynamically checkboxs I wait for u suggestions Regards ;) :rose:
-
Hello, I am developing a GMAO csharp smart device application.I am in the step of adding checkboxs dynamically:
I have two tables:Travaux (Works in English) and Actions related by the two fields Nature (table Travaux)and typeTravail(Table Actions).If the user enters the number of the work(NBT the pk_Travaux),the system adds a number of checkboxs equal to the steps that should the user follows to accomplish(field step in Actions table).After that,the user has the possibility to check or not the step if he did it.All the traitments will be done dynamically with the database
My select statement is:
select Etape from Action where ((Travaux.NBT=textbox1.text) and (Travaux.Nature=Action.TypeTravail))
Equal of what this select returns,it will add dynamically checkboxs I wait for u suggestions Regards ;) :rose:
Hi, After some search,I elaborate this code that still annoying :(( me with some errors:
private void button1_Click(object sender, EventArgs e)
{
//Create the connection
string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
SqlCeConnection sqlceconn = new SqlCeConnection(wCS);//Create the command SqlCeCommand command = sqlceconn.CreateCommand(); command.CommandText = "Select NBT, Nature from Travaux where NBT=@NBT "; //Add the parameters string s1 = textBox1.Text; //store the login name here YOU MUST FILL THIS IN SqlCeParameter NBT = new SqlCeParameter("@NBT", SqlDbType.NVarChar); NBT.Value = s1; command.Parameters.Add(NBT); //Create the adapter SqlCeDataAdapter adapter = new SqlCeDataAdapter(command); //Create and fill the dataset DataSet ds = new DataSet(); try { adapter.Fill(ds, "SQL Temp Table"); } catch (Exception ex) { MessageBox.Show(ex.Message); } foreach (DataRow da in adapter) { string s = adapter\["Nature"\]; } if ((ds.Tables.Count > 0) && (ds.Tables\["SQL Temp Table"\] != null)) { MessageBox.Show("Number of row(s) - " + ds.Tables\["SQL Temp Table"\].Rows.Count); if (ds.Tables\["SQL Temp Table"\].Rows.Count > 0) { MessageBox.Show("Numéro de BT trouvé"); SqlCeCommand command1 = sqlceconn.CreateCommand(); command1.CommandText = "Select NoEtape, Etape from Travaux where TypeTravail=@typ "; //Add the parameters string s2 = textBox1.Text; //store the login name here YOU MUST FILL THIS IN SqlCeParameter Typ = new SqlCeParameter("@Typ", SqlDbType.NVarChar); Typ.Value = s2; command1.Parameters.Add(Typ); SqlCeDataAdapter adapt = new SqlCeDataAdapter(command1); //Create and fill the dataset DataSet dat = new DataSet(); try { adapt.Fill(dat, "SQL Temp Table"); } catch (Exception ex) {