Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

db connection using sql client in dot net

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Myconstr"].ToString()); 

SqlCommand cmd = new SqlCommand("sprocUserinfoInsertUpdateSingleItem", con);  
                cmd.CommandType = CommandType.StoredProcedure;  
                cmd.Parameters.AddWithValue("@Name", ObjBO.Name);  
                cmd.Parameters.AddWithValue("@Address", ObjBO.address);  
                cmd.Parameters.AddWithValue("@EmailID", ObjBO.EmailID);  
                cmd.Parameters.AddWithValue("@Mobilenumber", ObjBO.Mobilenumber);   
             con.Open();  
             int Result = cmd.ExecuteNonQuery();   
             cmd.Dispose(); 
             
    // or 
    
    con.open();
    
    if (con.State.Equals(ConnectionState.Closed)) con.Open();  
                    SqlDataAdapter da = new SqlDataAdapter(cmd);  
                    dt = new DataTable();  
                    da.Fill(dt);  
                    con.Close();  
                    return dt; 
             
             
 
PREVIOUS NEXT
Tagged: #db #connection #sql #client #dot #net
ADD COMMENT
Topic
Name
1+8 =