Click here to Skip to main content
15,887,376 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to make Data Recovery Software using C# Pin
Richard Andrew x6420-Feb-18 10:04
professionalRichard Andrew x6420-Feb-18 10:04 
GeneralRe: How to make Data Recovery Software using C# Pin
phil.o20-Feb-18 12:49
professionalphil.o20-Feb-18 12:49 
AnswerRe: How to make Data Recovery Software using C# Pin
Gerry Schmitz20-Feb-18 10:45
mveGerry Schmitz20-Feb-18 10:45 
AnswerRe: How to make Data Recovery Software using C# Pin
Dave Kreskowiak20-Feb-18 13:50
mveDave Kreskowiak20-Feb-18 13:50 
AnswerRe: How to make Data Recovery Software using C# Pin
MadMyche22-Feb-18 4:44
professionalMadMyche22-Feb-18 4:44 
QuestionDateTimePicker Override right click events Pin
manju 319-Feb-18 23:36
manju 319-Feb-18 23:36 
AnswerRe: DateTimePicker Override right click events Pin
Ralf Meier20-Feb-18 0:34
mveRalf Meier20-Feb-18 0:34 
QuestionSQL Connection and insertion of data in C# form application Pin
Member 1368376518-Feb-18 1:09
Member 1368376518-Feb-18 1:09 
Hell everyone when i try to insert data through the c# windows application i got "InvalidOperationException" below i have attached my codings can any one help me?


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;
using System.Data.Sql;

namespace WindowsFormsApplication1
{
    public partial class frmBook : Form
    {


        SqlConnection con;

        SqlCommand cmd;
        SqlDataReader dr;


        public frmBook()
        {
            InitializeComponent();
        }

        private void lblStaffDetails_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void btnMainmenu_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmMainmenu op = new frmMainmenu();
            op.Show();
        }

        
       
            

        

        private void dGridBook_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void frmBook_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dbLibraryDataSet.tblBook' table. You can move, or remove it, as needed.
            this.tblBookTableAdapter.Fill(this.dbLibraryDataSet.tblBook);
            // TODO: This line of code loads data into the 'dbLibraryDataSet.tblBook' table. You can move, or remove it, as needed.
            this.tblBookTableAdapter.Fill(this.dbLibraryDataSet.tblBook);

            con = new SqlConnection();
            cmd = new SqlCommand();
            cmd.Connection = con;
        }

        private void btnSaveBook_Click(object sender, EventArgs e)
        {
            con.Open();
            cmd.CommandText = "insert into tblBook (Book_ID, Name, Authour, Category, Donater_ID, Section_ID) values ('" + txtBoxBookId.Text + "', '" + txtBoxBookName.Text + "', '" + txtBoxAuthour.Text + "', '" + txtBoxCategory.Text + "', '" + txtBoxDonaterId.Text + "', '" + txtBoxSecId.Text + "')";
            cmd.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Record is inserted", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void tblBookBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.tblBookBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.dbLibraryDataSet);

        }
    }
}

AnswerRe: SQL Connection and insertion of data in C# form application Pin
Richard MacCutchan18-Feb-18 1:39
mveRichard MacCutchan18-Feb-18 1:39 
AnswerRe: SQL Connection and insertion of data in C# form application Pin
Eddy Vluggen18-Feb-18 3:02
professionalEddy Vluggen18-Feb-18 3:02 
SuggestionRe: SQL Connection and insertion of data in C# form application Pin
Richard Deeming19-Feb-18 8:18
mveRichard Deeming19-Feb-18 8:18 
QuestionTesting methodologies Pin
Hila Berger18-Feb-18 0:54
Hila Berger18-Feb-18 0:54 
AnswerRe: Testing methodologies Pin
Richard MacCutchan18-Feb-18 1:35
mveRichard MacCutchan18-Feb-18 1:35 
AnswerRe: Testing methodologies Pin
Eddy Vluggen18-Feb-18 2:41
professionalEddy Vluggen18-Feb-18 2:41 
GeneralRe: Testing methodologies Pin
BillWoodruff18-Feb-18 9:53
professionalBillWoodruff18-Feb-18 9:53 
GeneralRe: Testing methodologies Pin
Eddy Vluggen18-Feb-18 10:36
professionalEddy Vluggen18-Feb-18 10:36 
AnswerRe: Testing methodologies Pin
BillWoodruff18-Feb-18 9:50
professionalBillWoodruff18-Feb-18 9:50 
QuestionSale Invoice Pin
Member 1368352817-Feb-18 20:37
Member 1368352817-Feb-18 20:37 
AnswerRe: Sale Invoice Pin
Richard MacCutchan17-Feb-18 21:06
mveRichard MacCutchan17-Feb-18 21:06 
AnswerRe: Sale Invoice Pin
OriginalGriff17-Feb-18 22:42
mveOriginalGriff17-Feb-18 22:42 
QuestionTop Level Properties Pin
User9874317-Feb-18 16:26
professionalUser9874317-Feb-18 16:26 
AnswerRe: Top Level Properties Pin
Mycroft Holmes17-Feb-18 22:34
professionalMycroft Holmes17-Feb-18 22:34 
AnswerRe: Top Level Properties Pin
BillWoodruff17-Feb-18 23:36
professionalBillWoodruff17-Feb-18 23:36 
GeneralRe: Top Level Properties Pin
User9874318-Feb-18 6:56
professionalUser9874318-Feb-18 6:56 
GeneralRe: Top Level Properties Pin
BillWoodruff18-Feb-18 8:22
professionalBillWoodruff18-Feb-18 8:22 

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.