Click here to Skip to main content
15,902,635 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to define an inline array of a contstant size in a C# structure Pin
Luc Pattyn30-Sep-09 0:45
sitebuilderLuc Pattyn30-Sep-09 0:45 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
maheesh30-Sep-09 2:42
maheesh30-Sep-09 2:42 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
Luc Pattyn30-Sep-09 2:56
sitebuilderLuc Pattyn30-Sep-09 2:56 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
maheesh30-Sep-09 3:35
maheesh30-Sep-09 3:35 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
Luc Pattyn30-Sep-09 3:49
sitebuilderLuc Pattyn30-Sep-09 3:49 
Questionhow to convert bmp image to hexa conversion ??? Pin
JC.KaNNaN29-Sep-09 21:02
JC.KaNNaN29-Sep-09 21:02 
AnswerRe: how to convert bmp image to hexa conversion ??? Pin
0x3c029-Sep-09 21:15
0x3c029-Sep-09 21:15 
GeneralRe: how to convert bmp image to hexa conversion ??? Pin
JC.KaNNaN29-Sep-09 23:00
JC.KaNNaN29-Sep-09 23:00 
GeneralRe: how to convert bmp image to hexa conversion ??? Pin
0x3c030-Sep-09 5:26
0x3c030-Sep-09 5:26 
QuestionAlter A query In Access using c# Pin
Abdul Rahman Hamidy29-Sep-09 20:43
Abdul Rahman Hamidy29-Sep-09 20:43 
AnswerRe: Alter A query In Access using c# Pin
Abdul Rahman Hamidy30-Sep-09 3:06
Abdul Rahman Hamidy30-Sep-09 3:06 
Questionchange property return type dynamically Pin
$unil Dhiman29-Sep-09 20:12
$unil Dhiman29-Sep-09 20:12 
AnswerRe: change property return type dynamically Pin
Christian Graus29-Sep-09 20:20
protectorChristian Graus29-Sep-09 20:20 
GeneralRe: change property return type dynamically Pin
$unil Dhiman29-Sep-09 20:33
$unil Dhiman29-Sep-09 20:33 
GeneralRe: change property return type dynamically Pin
Christian Graus29-Sep-09 22:12
protectorChristian Graus29-Sep-09 22:12 
Questiondatagrid combobox column Pin
Member 59031029-Sep-09 19:47
Member 59031029-Sep-09 19:47 
AnswerRe: datagrid combobox column Pin
Greg Chelstowski29-Sep-09 21:28
Greg Chelstowski29-Sep-09 21:28 
Questiondatetime picker in datagridview c# 2008 Pin
abcurl29-Sep-09 18:04
abcurl29-Sep-09 18:04 
AnswerRe: datetime picker in datagridview c# 2008 Pin
Not Active29-Sep-09 18:27
mentorNot Active29-Sep-09 18:27 
GeneralRe: datetime picker in datagridview c# 2008 Pin
abcurl29-Sep-09 18:30
abcurl29-Sep-09 18:30 
GeneralRe: datetime picker in datagridview c# 2008 Pin
Not Active29-Sep-09 18:37
mentorNot Active29-Sep-09 18:37 
QuestionRe: datetime picker in datagridview c# 2008 Pin
abcurl29-Sep-09 18:40
abcurl29-Sep-09 18:40 
AnswerRe: datetime picker in datagridview c# 2008 Pin
Not Active29-Sep-09 18:46
mentorNot Active29-Sep-09 18:46 
QuestionWCF,3Tier Pin
Member 232129329-Sep-09 17:47
Member 232129329-Sep-09 17:47 
QuestionModify a Dataset then apply dataset to sql server... What am I doing wrong Please? Pin
JollyMansArt29-Sep-09 12:25
JollyMansArt29-Sep-09 12:25 
Can Someone please help me. I am trying to learn the use of datasets....
I can easily grab the data without a dataset from this table and apply the changes back to the sql server. But when I use the dataset I can only retrieve the data from sql server. Everytime I try doing the following C# Code to update the data in a sql server table stored in a dataset then apply the dataset back to sql server. The Environment comes back to me and complains.

Here Is the error I keep getting:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.







private void btnOptionSaveChanges_Click(object sender, EventArgs e)
        {
            //http://support.microsoft.com/kb/307587
            //http://bytes.com/topic/c-sharp/answers/251248-reading-dataset
            //http://support.microsoft.com/kb/307587
            SQLObjects MySQLObjects = new SQLObjects();

                if (StandardProcedures.SQL_TestConnection(WhatIsMyConnectionString) == false)
                {
                    MessageBox.Show("There is an issue with the application's connection string or ability to communicate with SQL Server! No Changes will be made.");
                    //Environment.Exit(-1);
                    return;
                }
                if (!StandardProcedures.SQL_CheckToSeeIfTheObjectAlreadyExistsInSQLServer(WhatIsMyConnectionString, MySQLObjects.Table, "tblSoftwareControls"))
                {
                    MessageBox.Show("tblSoftwareControls table does not exist in the Database. No Changes will be made");
                    //Environment.Exit(-1);
                    return;
                }
                //string connString = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI";
                //string sql = @"select top 1 * from tblSoftwareControls";
                //string sql = @"SELECT CompanyName, CopyRight, ConnectionString, SplashScreenTimer, SplashScreenImage, VersionOverride FROM tblSoftwareControls";
                string sql = @"SELECT * FROM tblSoftwareControls";
                
                SqlConnection conn = new SqlConnection(WhatIsMyConnectionString);

                try
                {
                    conn.Open();
                    SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                    DataSet ds = new DataSet();
                    da.FillSchema(ds, SchemaType.Source, "tblSoftwareControls");
                    da.Fill(ds, "tblSoftwareControls");
                    //**************************************

                    //Update the dataset
                    DataTable dt = ds.Tables["tblSoftwareControls"];
                    DataRow dr;
                    if (dt.Rows.Count > 0)
                    {
                        dr = dt.Rows[0];
                        dr.BeginEdit();
                        dr["ConnectionString"] = txtApplicationConnectionString.Text;
                        dr["SplashScreenTimer"] = txtSplashScreenTimer.Text;
                        dr["VersionOverride"] = ckbxOverrideVersionByPass.Checked;
                        dr.EndEdit();
                        StandardProcedures.DebugLogWriter("Updated the record in tblSoftwareControls!");
                    }
                    else
                    {
                        dr = dt.NewRow();
                        dr["ConnectionString"] = txtApplicationConnectionString.Text;
                        dr["SplashScreenTimer"] = txtSplashScreenTimer.Text;
                        dr["VersionOverride"] = ckbxOverrideVersionByPass.Checked;
                        
                        //Pass the new object into the add method of the datatable
                        dt.Rows.Add(dr);
                        StandardProcedures.DebugLogWriter("Wrote a new record to tblSoftwareControls!");
                    }
                    //**************************************

                    //Update the sql database by sending it the data in the dataset.
                    // BEGIN SEND CHANGES TO SQL SERVER 

                    SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(da);
                    da.Update(ds, "tblSoftwareControls");
                    StandardProcedures.DebugLogWriter("DataSet modifications or additions or deletions has the modifications applied to the SQL Server Table.");
                    // END SEND CHANGES TO SQL SERVER
                        



                        /*

                    foreach (DataRow dr in dt.Rows)
                    {
                        txtApplicationConnectionString.Text = dr["ConnectionString"].ToString();
                        txtSplashScreenTimer.Text = dr["SplashScreenTimer"].ToString();
                        ckbxOverrideVersionByPass.Checked = StandardProcedures.Convert_TrueFalse(dr["VersionOverride"].ToString());
                    }
                    DataTable dt = ds.Tables["tblSoftwareControls"];
                    txtApplicationConnectionString.Text = dt.Columns["ConnectionString"].;
                    txtSplashScreenTimer.Text = dt.Columns["SplashScreenTimer"].;
                    ckbxOverrideVersionByPass.Checked = StandardProcedures.Convert_TrueFalse(dt.Columns["VersionOverride"]);
                    */
                }
                catch (Exception ex)
                {
                    StandardProcedures.ErrorLogWriter("Trying to populate the Options Tab: " + ex.ToString());    
                }
                finally
                {
                    conn.Close();
                }
        }

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.