3 ADO.NET跟踪日志

3.1.1 使用Logman.exe实用工具

 

代码
Imports  System.Data.SqlClient

Public   Class  MyApp
    
Shared   Sub  Main()
        
Dim  cnSettings  As  SqlConnectionStringBuilder
        
Dim  cn  As  SqlConnection
        
Dim  da  As  SqlDataAdapter
        
Dim  cmdBld  As  SqlCommandBuilder
        
Dim  ds  As  DataSet

        cnSettings 
=   New  SqlConnectionStringBuilder( _
                
" Data Source=.\ sqlexpress; "  _
            
&   " AttachDbFilename=|DataDirectory|northwnd.mdf; "  _
            
&   " Integrated Security=true;user instance=true " )
        cn 
=   New  SqlConnection(cnSettings.ConnectionString)
        da 
=   New  SqlDataAdapter( " Select * from Products " , cn)
        cmdBld 
=   New  SqlCommandBuilder(da)
        ds 
=   New  DataSet
        da.Fill(ds, 
" Products " )
        
For   Each  dr  As  DataRow  In  ds.Tables( " Products " ).Rows
            dr(
" UnitPrice " =  dr( " UnitPrice " *   1.1
        
Next
        da.Update(ds, 
" Products " )
    
End Sub
End Class

 

 

 

 

 

你可能感兴趣的:(.net)