Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regexp dilema Pin
Kythen21-Apr-10 6:00
Kythen21-Apr-10 6:00 
GeneralRe: Regexp dilema Pin
skelmannen21-Apr-10 21:28
skelmannen21-Apr-10 21:28 
QuestionStorage card in the emulator Pin
bacem smari20-Apr-10 23:53
bacem smari20-Apr-10 23:53 
AnswerRe: Storage card in the emulator Pin
Michel Godfroid21-Apr-10 2:03
Michel Godfroid21-Apr-10 2:03 
RantRe: Storage card in the emulator Pin
bacem smari21-Apr-10 2:54
bacem smari21-Apr-10 2:54 
AnswerRe: Storage card in the emulator Pin
bacem smari21-Apr-10 3:48
bacem smari21-Apr-10 3:48 
QuestionAdd checkboxs dynamically in csharp smart device project Pin
Tunisien8620-Apr-10 23:28
Tunisien8620-Apr-10 23:28 
GeneralRe: Add checkboxs dynamically in csharp smart device project Pin
Tunisien8621-Apr-10 5:26
Tunisien8621-Apr-10 5:26 
Hi,
After some search,I elaborate this code that still annoying Cry | :(( 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)
                    {
                        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 are those Sigh | :sigh:
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	

Thanks a lot for u suggestions:
Questiontype casting a string to a type which is getting received in a string Pin
dashingsidds20-Apr-10 23:20
dashingsidds20-Apr-10 23:20 
AnswerRe: type casting a string to a type which is getting received in a string Pin
surender.m20-Apr-10 23:34
surender.m20-Apr-10 23:34 
GeneralRe: type casting a string to a type which is getting received in a string Pin
J4amieC21-Apr-10 1:40
J4amieC21-Apr-10 1:40 
GeneralRe: type casting a string to a type which is getting received in a string Pin
surender.m21-Apr-10 1:47
surender.m21-Apr-10 1:47 
GeneralRe: type casting a string to a type which is getting received in a string Pin
J4amieC21-Apr-10 1:50
J4amieC21-Apr-10 1:50 
AnswerRe: type casting a string to a type which is getting received in a string Pin
Keith Barrow20-Apr-10 23:39
professionalKeith Barrow20-Apr-10 23:39 
AnswerRe: type casting a string to a type which is getting received in a string Pin
surender.m21-Apr-10 3:27
surender.m21-Apr-10 3:27 
GeneralRe: type casting a string to a type which is getting received in a string Pin
dashingsidds21-Apr-10 22:42
dashingsidds21-Apr-10 22:42 
AnswerRe: type casting a string to a type which is getting received in a string Pin
PIEBALDconsult21-Apr-10 3:57
mvePIEBALDconsult21-Apr-10 3:57 
QuestionSending a Custom Ethernet packet Pin
spiritboy20-Apr-10 22:48
spiritboy20-Apr-10 22:48 
QuestionICCompress Pin
TimSWatson20-Apr-10 22:38
TimSWatson20-Apr-10 22:38 
QuestionFileSystemWatcher problem when multi-files deletion in watched folder Pin
Rikq20-Apr-10 22:31
Rikq20-Apr-10 22:31 
QuestionHow to search Special Character in sql server 2005? [modified] Pin
Ashwani Dhiman20-Apr-10 22:11
Ashwani Dhiman20-Apr-10 22:11 
AnswerRe: How to search Special Character in sql server 2005? Pin
Ice_Freez0520-Apr-10 22:19
Ice_Freez0520-Apr-10 22:19 
QuestionSave XML Pin
NarVish20-Apr-10 22:04
NarVish20-Apr-10 22:04 
AnswerRe: Save XML Pin
Ice_Freez0520-Apr-10 22:22
Ice_Freez0520-Apr-10 22:22 
GeneralRe: Save XML Pin
NarVish20-Apr-10 23:20
NarVish20-Apr-10 23:20 

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.