none
How to new row in Database use EF & BindingSource RRS feed

  • Question

  • I'm writing a Windows application (.NET 4), SQL Server 2008 and EF 4.0:

    Table "Currencies" in SQL Server is:

    ID smallint (auto increment) PK
    Name nvarchar(100) NOT NULL
    Code nvarchar(10) NOT NULL
    Rate float NOT NULL
    IsAfter smallint NOT NULL (Default Value = 0)

    Window Form Currency.cs:

    Name: TextBox with property DataBinding.Text = bindingCurrency - Name
    Code: TextBox with property DataBinding.Text = bindingCurrency - Code
    Rate: TextBox with property DataBinding.Text = bindingCurrency - Rate
    Show before/after money: ComboBox with property DataBinding.Text = bindingCurrency - IsAfter
        ComboBox follow:
            0 | Before money
            1 | After money

    bindingCurrency: BindingSource with property DataSource is entity of EF

    Now I want to add currency but it's error. Can you help me???


    Saturday, September 7, 2013 6:29 PM

Answers

  • Hi Henry;

    When using a BindingSource you can use the AddNew() method of the BindingSource. Please see the documentation for information on [AddNew() method].

    Also you state that it errors out, please post the exact error Message and any inner exception message that you are getting.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 9, 2013 7:13 PM

All replies

  • Somebody help me???
    Sunday, September 8, 2013 9:28 AM
  • Hi,

    Since this issue is related to EF I've moved it to the right forum.

    Regards,


    Barry Wang
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 9, 2013 9:56 AM
  • Ok, thanks. But nobody helps me....
    Monday, September 9, 2013 2:15 PM
  • Hi Henry;

    When using a BindingSource you can use the AddNew() method of the BindingSource. Please see the documentation for information on [AddNew() method].

    Also you state that it errors out, please post the exact error Message and any inner exception message that you are getting.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 9, 2013 7:13 PM