Using a button to initiate a sql data source insert

Posted on 2007-10-08
Last Modified: 2013-11-26
I have created a sql data source that inserts a row into a table and I want a button to initiate or run it.  Can someone give me the code to do this.   Do I have to generate code with a Button Click or can I set it up with a property?
Question by:keithwilson1
    LVL 5

    Expert Comment

    If all you want to do is activate the datasource from the button click, simply add it to the click event of the button, then make the calls to your datasource. I am not sure what type of code you are looking for as you have given no information about the datasource you have

    It could be something as simple as

    private void button2_Click(object sender, EventArgs e)
          YourDataSource ds = new YourDataSource();

    Author Comment

    Could you give me the VB version?

    Author Comment

    In VB, I am getting ,"DoInsert is not a member of System.Web.UI.WebControls.SqlDataSource."  
    LVL 5

    Accepted Solution

    DoInsert was only an example. I do not know anything baout your datasource class to know exactly what calls you need to execute.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Contant UI messages in .NET 1 17
    C# - SOLID Question 6 35
    Problem to event 3 25
    .NET NamedPipe access using ip address 5 17
    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now