MySqlCommand comm = connect.CreateCommand();
comm.CommandText = insertStatement; // Set the insert statement
comm.ExecuteNonQuery(); // Execute the command
long id = comm.LastInsertedId; // Get the ID of the inserted item
More Related Contents:
- Error: You have an error in your SQL syntax – but SQL statement works
- Quotes in string [closed]
- is there a more efficient way to write this sql code?
- Parameterized Query for MySQL with C#
- LINQ to Entities does not recognize the method ‘System.String ToString()’ method, and this method cannot be translated into a store expression
- How to connect to MySQL Database?
- Configuration System Failed to Initialize
- .NET Core 2.1 Identity get all users with their associated roles
- ASP.NET use SqlConnection connect MySQL
- Most efficient way to insert Rows into MySQL Database
- MySqlCommand Command.Parameters.Add is obsolete
- LINQ to SQL multiple tables left outer join
- Enable Entity Framework 6 for MySql (C#) in WinForms of Microsoft Visual Studio 2013
- Dynamic MySQL database connection for Entity Framework 6
- C# with MySQL INSERT parameters
- Unable to connect to any of the specified mysql hosts. C# MySQL
- Why do I get “System.Data.DataRowView” instead of real values in my WinForms Listbox?
- Entity Framework creates a plural table name, but the view expects a singular table name?
- MySQL Entity Framework Error – The specified store provider cannot be found in the configuration, or is not valid
- Asking for legitimate example of calling stored procedure C#: MYSQL
- Using SqlDataAdapter to insert a row
- Get affected rows on ExecuteNonQuery
- Index (zero based) must be greater than or equal to zero
- How to pass a table as parameter to MySqlCommand?
- Connection to MySQL from .NET using SSH.NET Library
- Testing an Entity Framework database connection
- How can I force a log out of all users for a website?
- How do I remove emoji characters from a string?
- Incorrect string value: ‘\xEF\xBF\xBD’ for column
- Could not load file or assembly ‘MySql.Data, Version=6.2.2.0