![](/style/images/good.png)
![](/style/images/bad.png)
ExecuteNonQuery Result in C #
source link: https://www.codesd.com/item/executenonquery-result-in-c.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
ExecuteNonQuery Result in C #
How can i know if i create a database successfully? I am using "CREATE DATABASE DemoDB"
as a SQL command. ExecuteNonQuery()
method returns 0. What should i use to understand if i created a database successfully?
ExecuteNonQuery throws a MySqlException exception if there is an error. It returns 0 if successful but you don't need to check the return value; if it returns normally it has succeeded. For example here is the exception I get when I try to create a database that already exists:
Can't create database 'name'; database exists
Related Articles
Pass the parameter to the stored procedure in C #
SQL Server 2008 R2 Express Edition - Exception
Validate connection errors
The invalid connection giving a specified casting is invalid
Error while running the MySQL query
With regard to not calling enquiry.cs in the application code
(VB.NET) Syntax error in INSERT INTO statement - MICROSOFT JET DATABASE ENGINE
Converting the DbCommand Object to the OracleCommand Object
The easiest way to create the database from the connection string?
How can you update based on the results of an IF statement in the query?
If a query contains two update statements, what does ExecuteNonQuery () return?
How do I export the results of a stored procedure directly to an MS Excel file?
Why does this method that runs this simple query give me a bad result?
SQL query always Return -1 as a result c # asp.net
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK