Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
AnswerRe: I need free C# TreeList( or TreeView) code that will run on the web form Pin
#realJSOP8-Oct-08 2:59
mve#realJSOP8-Oct-08 2:59 
Questionstatic Object Pin
Deepak the Cool8-Oct-08 1:20
Deepak the Cool8-Oct-08 1:20 
AnswerRe: static Object Pin
Colin Angus Mackay8-Oct-08 2:08
Colin Angus Mackay8-Oct-08 2:08 
QuestionCentralized exception handler and logger Pin
matixsc8-Oct-08 0:57
professionalmatixsc8-Oct-08 0:57 
AnswerRe: Centralized exception handler and logger Pin
Giorgi Dalakishvili8-Oct-08 1:14
mentorGiorgi Dalakishvili8-Oct-08 1:14 
AnswerRe: Centralized exception handler and logger Pin
matixsc8-Oct-08 2:16
professionalmatixsc8-Oct-08 2:16 
QuestionRe:Installing Flash player with windows set up Pin
RameshwerE8-Oct-08 0:19
RameshwerE8-Oct-08 0:19 
QuestionUpdate requires a valid UpdateCommand when passed DataRow collection with modified rows. [modified] Pin
astrovirgin7-Oct-08 23:36
astrovirgin7-Oct-08 23:36 
Hi,
I am inserting and updating the database using the DataGridView. But when I insert or update the table in the database I got this error:"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."

I am writing the code here.

private void btnInsert_Click(object sender, EventArgs e)
{
    sqlDataAdapter.Update((DataTable)bindingSource.DataSource);//Here I am getting the error.
}

private void Form1_Load(object sender, EventArgs e)
{
    dataGridView1.DataSource = bindingSource;
    PopulateDataGridView();

}

private void PopulateDataGridView()
{
    try
    {
       String sqlCommand = "select * from " + tableName;

       sqlDataAdapter = new SqlDataAdapter(sqlCommand, connString);

       SqlCommandBuilder commandBuilder = new SqlCommandBuilder(sqlDataAdapter);

       DataSet dsData = new DataSet();
       dsData.Locale = CultureInfo.InvariantCulture;

       sqlDataAdapter.Fill(dsData);

       bindingSource.DataSource=dsData.Tables[0];


    }
    catch (SqlException sqlException)
    {
        MessageBox.Show(sqlException.Message.ToString());
    }

}


Everything is working fine but when I click on the Insert Button it gives me error. Please Help.

modified on Wednesday, October 8, 2008 6:19 AM

AnswerRe: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Pin
Giorgi Dalakishvili8-Oct-08 0:23
mentorGiorgi Dalakishvili8-Oct-08 0:23 
AnswerRe: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Pin
nelsonpaixao8-Oct-08 12:47
nelsonpaixao8-Oct-08 12:47 
QuestionProblem with free up memory! Pin
Ha ha ha ha ha ha ha ha7-Oct-08 23:24
Ha ha ha ha ha ha ha ha7-Oct-08 23:24 
AnswerRe: Problem with free up memory! Pin
Simon P Stevens8-Oct-08 0:11
Simon P Stevens8-Oct-08 0:11 
GeneralRe: Problem with free up memory! Pin
leppie8-Oct-08 1:53
leppie8-Oct-08 1:53 
GeneralRe: Problem with free up memory! Pin
Ha ha ha ha ha ha ha ha8-Oct-08 1:54
Ha ha ha ha ha ha ha ha8-Oct-08 1:54 
GeneralRe: Problem with free up memory! Pin
Simon P Stevens8-Oct-08 3:06
Simon P Stevens8-Oct-08 3:06 
GeneralRe: Problem with free up memory! Pin
Ha ha ha ha ha ha ha ha8-Oct-08 3:51
Ha ha ha ha ha ha ha ha8-Oct-08 3:51 
GeneralRe: Problem with free up memory! Pin
Simon P Stevens8-Oct-08 4:42
Simon P Stevens8-Oct-08 4:42 
GeneralRe: Problem with free up memory! Pin
DaveyM698-Oct-08 5:58
professionalDaveyM698-Oct-08 5:58 
GeneralRe: Problem with free up memory! Pin
Simon P Stevens8-Oct-08 22:58
Simon P Stevens8-Oct-08 22:58 
GeneralRe: Problem with free up memory! [modified] Pin
Mark Salsbery8-Oct-08 8:07
Mark Salsbery8-Oct-08 8:07 
GeneralRe: Problem with free up memory! Pin
Ha ha ha ha ha ha ha ha9-Oct-08 20:50
Ha ha ha ha ha ha ha ha9-Oct-08 20:50 
QuestionGet a whole column in a matrix Pin
xkrja7-Oct-08 21:37
xkrja7-Oct-08 21:37 
AnswerRe: Get a whole column in a matrix Pin
User 66587-Oct-08 21:48
User 66587-Oct-08 21:48 
QuestionHow to get whitespace in xml Pin
manju#1237-Oct-08 19:52
manju#1237-Oct-08 19:52 
AnswerRe: How to get whitespace in xml Pin
Pedram Behroozi7-Oct-08 20:18
Pedram Behroozi7-Oct-08 20:18 

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.