Imports System.Data.SqlClient Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim command As New SqlCommand command.CommandText = "INSERT tablename VALUES (@id)" Dim pId As New SqlParameter("@id", SqlDbType.Int) pId.Value = 627 command.Parameters.Add(pId) Dim log As New Log Using cn As New SqlConnection("Server=xxx;Integrated Security=True;") log.Write(command.CommandText) For Each param As SqlParameter In command.Parameters log.Write(param.ParameterName & "=" & param.Value.ToString) Next cn.Open() command.ExecuteNonQuery() cn.Close() End Using End Sub End Class Public Class Log Public Property LogPath As String = "C:\test\sql.log" Public Sub Write(text As String) My.Computer.FileSystem.WriteAllText(LogPath, text & vbNewLine, True) End Sub End Class