Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2008, 01:58 PM
Authorized User
 
Join Date: Jan 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default Database wont save, gett error message

Hello advanced programmers. Im pretty new to programming databases in c# and for some reson my database will not save. Please take a look at my code, any advice and help would be appriciated.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FilmDatabase
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void mainBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.MainBindingSource.EndEdit();
            this.TypeBindingSource.EndEdit();

            FilmDBDataSet.MainDataTable tabelChanges = FilmDBDataSet.Main.GetChanges(DataRowState.Added | DataRowState.Modified) as FilmDBDataSet.MainDataTable;
            if (tabelChanges != null)
            {
                MainTableAdapter.Update(tabelChanges);
            }

            TypeTableAdapter.Update(FilmDBDataSet.Type);
            StatusTableAdapter.Update(FilmDBDataSet.Status);

            FilmDBDataSet.MainDataTable tableDeletes = FilmDBDataSet.Main.GetChanges(DataRowState.Deleted) as FilmDBDataSet.MainDataTable;
            if (tabelChanges != tableDeletes)
            {
                MainTableAdapter.Update(tableDeletes);
            }

            FilmDBDataSet.AcceptChanges();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'FilmDBDataSet.Status' table. You can move, or remove it, as needed.
            this.StatusTableAdapter.Fill(this.FilmDBDataSet.Status);
            // TODO: This line of code loads data into the 'FilmDBDataSet.Type' table. You can move, or remove it, as needed.
            this.TypeTableAdapter.Fill(this.FilmDBDataSet.Type);
            // TODO: This line of code loads data into the 'filmDBDataSet.Main' table. You can move, or remove it, as needed.
            this.MainTableAdapter.Fill(this.FilmDBDataSet.Main);
        }
        private void MainBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            DataView dataTableView = MainBindingSource.List as DataView;
            DataRowView rowView = dataTableView.AddNew();

            rowView["ID"] = Guid.NewGuid();
            rowView["TypeID"] = (MainBindingSource.Current as DataRowView)["TypeID"];
            rowView["StatusID"] = (MainBindingSource.Current as DataRowView)["StatusID"];
            rowView["Name"] = "Name";
            rowView["Release"] = "0";

            e.NewObject = rowView;

            MainBindingSource.MoveLast();
        }

        private void statusBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            DataView dataTableView = StatusBindingSource.List as DataView;
            DataRowView rowView = dataTableView.AddNew();

            rowView["StatusID"] = Guid.NewGuid();
            rowView["Status"] = "";

            e.NewObject = rowView;

            StatusBindingSource.MoveLast();
        }

        private void mainDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            if (e.Exception is NoNullAllowedException)
            {
            }
            else
            {
                e.ThrowException = true;
            }
        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {

        }
    }
}
 
Old December 13th, 2008, 02:11 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What is the Error message?
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old December 13th, 2008, 03:07 PM
Authorized User
 
Join Date: Jan 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default Here is the error message

Here is the error that im getting.

http://img246.imageshack.us/img246/5892/erroriw2.jpg





Similar Threads
Thread Thread Starter Forum Replies Last Post
parameterized tableadapter wont save to access dat edubnmrg Pro VB Databases 0 June 13th, 2006 01:42 PM
print/save functions and error message bryan.lugo Excel VBA 0 May 1st, 2006 09:29 AM
Error message on database Brendan Bartley Access 1 October 21st, 2005 11:52 AM
Database Error message when opening Brendan Bartley Access 1 July 19th, 2005 12:26 PM
Error Message When Any Database Opens Ben Horne Access 4 March 11th, 2004 05:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.