Click here to Skip to main content
15,888,802 members
Home / Discussions / C#
   

C#

 
AnswerRe: Trasnfer Data in datagrid in form1 to Text box in form2 Pin
DaveyM6921-Apr-10 11:01
professionalDaveyM6921-Apr-10 11:01 
Questioncrystal reports Pin
jojoba201121-Apr-10 7:52
jojoba201121-Apr-10 7:52 
QuestionConverting Pixel to twips Pin
jojoba201121-Apr-10 7:01
jojoba201121-Apr-10 7:01 
AnswerRe: Converting Pixel to twips Pin
Henry Minute21-Apr-10 7:17
Henry Minute21-Apr-10 7:17 
GeneralRe: Converting Pixel to twips Pin
Not Active21-Apr-10 13:00
mentorNot Active21-Apr-10 13:00 
GeneralRe: Converting Pixel to twips Pin
Dan Mos21-Apr-10 13:15
Dan Mos21-Apr-10 13:15 
AnswerRe: Converting Pixel to twips Pin
Luc Pattyn21-Apr-10 7:48
sitebuilderLuc Pattyn21-Apr-10 7:48 
QuestionCreating a checklist using checkbox tool in csharp smart device project Pin
Tunisien8621-Apr-10 6:06
Tunisien8621-Apr-10 6:06 
Hello,
I am developing a GMAO csharp smart device application.I am in the step of creating a checklist using checkbox tool added 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 tried with this code but not working due to some errors Cry | :((
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)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    foreach (DataRow ligne in adapt.)
                    {
                        System.Console.WriteLine(adapt[0]);
                    }


                    
                }
                else MessageBox.Show("Veuillez saisir un autre NBT");
            }
            adapter.Dispose();
            sqlceconn.Dispose();
            command.Dispose();

        }

The errors areMad | :mad: :
Error 1 foreach statement cannot operate on variables of type 'System.Data.SqlServerCe.SqlCeDataAdapter' because 'System.Data.SqlServerCe.SqlCeDataAdapter' does not contain a public definition for 'GetEnumerator'	C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Travail.cs
Error	2	Cannot apply indexing with [] to an expression of type 'System.Data.SqlServerCe.SqlCeDataAdapter'	C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Travail.cs	
Error	3	foreach statement cannot operate on variables of type 'System.Data.SqlServerCe.SqlCeDataAdapter' because 'System.Data.SqlServerCe.SqlCeDataAdapter' does not contain a public definition for 'GetEnumerator'	C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Travail.cs	
Error	4	Cannot apply indexing with [] to an expression of type 'System.Data.SqlServerCe.SqlCeDataAdapter'	C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Travail.cs	

I wait for u help Frown | :(
Thanks
AnswerRe: Creating a checklist using checkbox tool in csharp smart device project Pin
Tarakeshwar Reddy21-Apr-10 9:04
professionalTarakeshwar Reddy21-Apr-10 9:04 
GeneralRe: Creating a checklist using checkbox tool in csharp smart device project Pin
Tunisien8621-Apr-10 22:53
Tunisien8621-Apr-10 22:53 
GeneralRe: Creating a checklist using checkbox tool in csharp smart device project Pin
Tarakeshwar Reddy22-Apr-10 6:23
professionalTarakeshwar Reddy22-Apr-10 6:23 
AnswerRe: Creating a checklist using checkbox tool in csharp smart device project Pin
Tunisien8622-Apr-10 6:27
Tunisien8622-Apr-10 6:27 
QuestionHow to pad a string with zeroes Pin
jkpieters21-Apr-10 4:41
jkpieters21-Apr-10 4:41 
AnswerRe: How to pad a string with zeroes Pin
OriginalGriff21-Apr-10 4:51
mveOriginalGriff21-Apr-10 4:51 
GeneralRe: How to pad a string with zeroes Pin
jkpieters21-Apr-10 4:58
jkpieters21-Apr-10 4:58 
GeneralRe: How to pad a string with zeroes Pin
OriginalGriff21-Apr-10 5:15
mveOriginalGriff21-Apr-10 5:15 
GeneralRe: How to pad a string with zeroes Pin
PIEBALDconsult21-Apr-10 6:00
mvePIEBALDconsult21-Apr-10 6:00 
GeneralRe: How to pad a string with zeroes Pin
OriginalGriff21-Apr-10 6:07
mveOriginalGriff21-Apr-10 6:07 
GeneralRe: How to pad a string with zeroes Pin
PIEBALDconsult21-Apr-10 6:17
mvePIEBALDconsult21-Apr-10 6:17 
GeneralRe: How to pad a string with zeroes Pin
OriginalGriff21-Apr-10 6:24
mveOriginalGriff21-Apr-10 6:24 
AnswerRe: How to pad a string with zeroes [modified] Pin
PIEBALDconsult21-Apr-10 5:00
mvePIEBALDconsult21-Apr-10 5:00 
AnswerRe: How to pad a string with zeroes Pin
OkkiePepernoot21-Apr-10 5:29
OkkiePepernoot21-Apr-10 5:29 
AnswerRe: How to pad a string with zeroes Pin
Luc Pattyn21-Apr-10 6:33
sitebuilderLuc Pattyn21-Apr-10 6:33 
GeneralRe: How to pad a string with zeroes Pin
PIEBALDconsult21-Apr-10 7:50
mvePIEBALDconsult21-Apr-10 7:50 
GeneralRe: How to pad a string with zeroes Pin
Luc Pattyn21-Apr-10 7:57
sitebuilderLuc Pattyn21-Apr-10 7:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.