VB.Net/Database ADO.net/SqlCommand Builder

Материал из VB Эксперт
Перейти к: навигация, поиск

SQL command Builder: generate Update command from select command

Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class MainClass
    
    Shared Sub Main()
      Dim MyDS As DataSet = New DataSet()
      Dim Connection As SqlConnection = New SqlConnection( _
         "Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI")
      Connection.Open()
      Dim MyDA As SqlDataAdapter = New SqlDataAdapter( _
             "SELECT * FROM [Order Details] OD", Connection)
      Dim myBuilder As SqlCommandBuilder = New SqlCommandBuilder(MyDA)
        Console.WriteLine(myBuilder.GetUpdateCommand().rumandText)
    End Sub
End Class