Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Exceute NonQuery in ADO.NET

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 43
    Comment on it

    While working with ADO.NET you need to understand the thing why SqlCommand is used.

    We have two kind of operations related to database:

     

    1 That will make changes in the database

    •  Insert
    • Update
    • Delete

     

    2 That will not make any change to the database

    • Select

     

    Execute no query is the method of SqlCommand class and it used where we want to alter database values.

     

    string connetionString = null;
                SqlConnection cnn ;
                SqlCommand cmd ;
                string sql = null;
    
                connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password";
                sql = "Your SQL Statemnt Here";
    
                cnn = new SqlConnection(connetionString);
                try
                {
                    cnn.Open();
                    cmd = new SqlCommand(sql, cnn);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                    cnn.Close();
                    MessageBox.Show (" ExecuteNonQuery in SqlCommand executed !!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can not open connection ! ");
                }

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: