Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Sql Command without stored procedure

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 47
    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

     

    SqlCommand is used for the first one when we have insert update or delete operation to perform in the database.

    For this we always have to open the connection to make changes to the database.

    And after finishing work connection should be closed.

    SqlConnection conObj=new SqlConnection("");
    
    SqlCommand cmdInsert = new SqlCommand("INSERT INTO client(name,surname) values(@name,@surname)", conObj);
    
    cmdInsert.Parameters.AddWithValue("@name", name.Text);
    
    cmdInsert.Parameters.AddWithValue("@surname", surname.Text);
    
    conObj.Open();
    
    cmdInsert.ExecuteNonQuery();
    
    
    .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: