Insert data into Database
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll http://stackoverflow.com/questions/16640450/executenonquery-sql-asp-net-error be auto redirected in 1 second. System.Data.SqlClient SqlCommand Class SqlCommand Methods SqlCommand Methods ExecuteNonQuery Method ExecuteNonQuery Method ExecuteNonQuery Method BeginExecuteNonQuery Method BeginExecuteReader Method BeginExecuteXmlReader Method Cancel Method Clone Method CreateParameter Method EndExecuteNonQuery Method EndExecuteReader Method EndExecuteXmlReader Method ExecuteNonQuery Method https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery(v=vs.110).aspx ExecuteNonQueryAsync Method ExecuteReader Method ExecuteReaderAsync Method ExecuteScalar Method ExecuteScalarAsync Method ExecuteXmlReader Method ExecuteXmlReaderAsync Method Prepare Method ResetCommandTimeout Method IDbCommand.ExecuteReader Method ICloneable.Clone Method TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. SqlCommand.ExecuteNonQuery Method () .NET Framework (current version) Other Versions Visual Studio 2010 .NET Framework 4 Visual Studio 2008 .NET Framework 3.5 .NET Framework 3.0 .NET Framework 2.0 .NET Framework 1.1 Executes a Transact-SQL statement against the connection and returns the number of rows affected.Namespace: System.Data.SqlClientAssembly: System.Data (in System.Data.dll)Syntax C#C++F#VB Copy public override int ExecuteNonQuery() Return Value Type: System.Int32The number of rows affected.ImplementsIDbCommand.ExecuteNonQuery()Exce
1 of 1 New Topic/Question Reply 5 Replies - 9957 Views - Last Post: 23 April 2012 - 06:48 AM Rate Topic: #1 vikxit http://www.dreamincode.net/forums/topic/276374-cmdexecutenonquery-error-when-updating-to-database/ New D.I.C Head Reputation: 1 Posts: 16 Joined: 23-April 12 cmd.ExecuteNonQuery() Error when updating to database Posted 23 April 2012 - 01:10 AM Hello, I'm trying to http://www.c-sharpcorner.com/forums/executenonquery-connection-property-has-not-been-initialize update a record in MS Access database with the code below. But it says 'Syntax error in UPDATE statement and highlights cmd.ExecuteNonQuery()'. Can anyone help on this? Here's error in the code: dbconnect.Open() Dim cmd As New OleDb.OleDbCommand cmd.Connection = dbconnect 'chek whether add new or update If Me.txtCustomerID.Tag & "" = "" Then 'add new 'add data to table cmd.CommandText = "INSERT INTO tblCustomer(Customer_ID, First_Name, Last_Name, Gender, Telephone_No, Address, Line_1, Line_2, Email_Add, Registered_Date)" & _ "VALUES(" & Me.txtCustomerID.Text & ",'" & Me.txtFirstName.Text & "','" error in executenonquery & Me.txtLastName.Text & "','" & Me.comboGender.Text & "','" & Me.txtTelNo.Text & "','" & Me.txtAddress.Text & "','" & _ Me.txtLine1.Text & "','" & Me.txtLine2.Text & "','" & Me.txtEmailAdd.Text & "',#" & Me.dtpDate.Text & "#)" cmd.ExecuteNonQuery() Else 'update data in table cmd.CommandText = "UPDATE tblCustomer" & _ "SET Customer_ID=" & Me.txtCustomerID.Text & _ ", First_Name'" & Me.txtFirstName.Text & "'" & _ ", Last_Name'" & Me.txtLastName.Text & "'" & _ ", Gender'" & Me.comboGender.Text & "'" & _ ", Telephone_No'" & Me.txtTelNo.Text & "'" & _ ", Address" & Me.txtAddress.Text & "'" & _ ", Line_1'" & Me.txtLine1.Text & "'" & _ ", Line_2'" & Me.txtLine2.Text & "'" & _ ", Email_Add'" & Me.txtEmailAdd.Text & "'" & _ ", Registered_Date'" & Me.dtpDate.Text & "'" & _ "WHERE Customer_ID=" & Me.txtCustomerID.Tag cmd.ExecuteNonQuery() End If dbconnect.Close() Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: cmd.ExecuteNonQuery() Error when updating to database #2 CharlieMay This space intentionally left blank Reputation: 1726 Posts: 5,696 Joined
DOWNLOAD: C# Corner Android App Version 0.5.3 Released C# Corner Annual Conference 2017 Announced Forums - C# Corner C# Corner Home Technologies Monthly Leaders ASK A QUESTION C# Programming Multi-threading IoT Coffee, Chai Lounge HTML, JavaScript, CSS .NET General Office Interoperability Microsoft Surface Community Services iPhone, iPad Active Directory Printing ReFS Current Affairs Java ADO.NET & Database Project Management Silverlight 5 Fun and Jokes JQuery AJAX & Atlas Remoting WCF Job Opportunities JSP Algorithms & AI Reporting Windows 8 Leadership Multimedia, Graphics, Flash Arrays & Collections Robotics and Hardware Windows Azure Mac for Windows Node.js ASP.NET & Web Development Security & Cryptography Windows Store Apps Microsoft Feedback PHP C# Language Setup & Deployment Workflow Foundation Open Source Projects Social Networking C# References Sharepoint WPF Operating Systems TypeScript CLR & .NET Internals Speech & Voice Recognition XAML Language Paid Projects Web Hosting COM Interoperability Tablet PC Site and Forums Feedback Prizes, Awards, MVP Website Management Custom Controls Testing and QA Announcements Students & Beginner Projects Windows Phone 7 Design and Architecture Visual Basic .NET Author Guidelines Test Category Database Embedded Development Visual C++ Bugs and Problems Training & Certification Database General Enterprise Development Visual Studio 11 Forums Feedback Web Development Oracle Games, DirectX, and XNA Visual Studio 2010 Site Feedback & Suggestions Advertising, Marketing, SEO SQL GDI+ and DirectX Web Services Site Spams Android SQL Server General Windows Forms Miscellaneous AngularJS Products LINQ Windows Services .NET Books Cloud Computing Office 2013 Migrating to .NET Cutting-Edge Ask the Author Expression Tools Products Mobile Development .NET 5.0 Career Advice HTML 5 SharePoint 2013 Forum guidelines Home ASP.NET & Web Development ExecuteNonQuery: Connection property has not been initialize parthiban karnan 1.3k 40 38.7k ExecuteNonQuery: Connection property has not been initialize Apr 19 2013 4:44 AM String strConnString = ConfigurationManager.ConnectionStrings["EMPLOYEEConnectionString2"].ConnectionString; //SqlConnection con = new SqlConnection(); protected void btnSave_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(strConnString); con.Open(); // con.ConnectionString = new SqlConnection(strC