Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on my first C# SQL project. A simple checkbook register.

I referred to the CodeProject article:

Using the DataGrid Control: Using the DataGrid Control[^]

I added a datagridview control to my form and set the data source as my checkbook register in SQL Express.

I am able to see all the checkbook entries when I run the form.

My first attempt at updating the sql table is generating a compile error.

The error is:
cannot convert from 'System.Data.DataSet' to 'FirstCheckBookInSQL.CheckBookManagementDataSet.CheckbookUSBPersonalDataTable'

I've been researching this for 3 days, but I'm just not making sense of what I am seeing.

Can someone help please!
Thank you.
Mark


My code in Form1.cs:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FirstCheckBookInSQL
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'checkBookManagementDataSet.CheckbookUSBPersonal' table. You can move, or remove it, as needed.
            this.checkbookUSBPersonalTableAdapter.Fill(this.checkBookManagementDataSet.CheckbookUSBPersonal);
        }
        private void TBDbutton_Click(object sender, EventArgs e)
        {
            DataSet myChangedDataSet = this.checkBookManagementDataSet.GetChanges();
            if (myChangedDataSet != null)
            {
                // get how many rows changed


<big>// this is the line of code I am getting the error on:
                int modifiedRows = this.checkbookUSBPersonalTableAdapter.Update(myChangedDataSet);</big>
                //MessageBox.Show("Database has been updated successfully: " +
                //modifiedRows + " Modified row(s) ", "Success");
                this.checkBookManagementDataSet.AcceptChanges();
                myChangedDataSet.AcceptChanges();
            }
            MessageBox.Show("no data changed");
        }
    }
}
Posted
Comments
Sandeep Mewara 1-Sep-10 16:31pm    
Added info by OP: The adapter was added automatically by Visual Studio 2008 when I placed the DataGridView

I suspect you want to talk to the article author, there's a forum for that under the article. I can't see why you have an object called CheckbookUSBPersonalDataTable in your project based on this code, it apparently you do, and a table adapter to go with it.
 
Share this answer
 
have you tried this?

int modifiedRows = this.checkbookUSBPersonalTableAdapter.Update(myChangedDataSet.Tables[0]);
 
Share this answer
 
Comments
mpanger 1-Sep-10 18:01pm    
Yes and with the same compile error.
Mark :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900