Are there ways to add 2 Table when using the INSER

2019-08-02 06:35发布

问题:

It seems like the query builder in vb only allow 1 table to use the INSERT statement, so are there any way add more than 1?

回答1:

You should be able to wrap them all into one command call. Here is an example of what I think you are looking for.

how to insert into two tables from vb.net



回答2:

Using con As System.Data.SqlClient.SqlConnection = New SqlConnection("YourConnection string")
    con.Open()
    Dim cmd As New SqlCommand()
    Dim expression As String = "Parameter value"
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = "Your Stored Procedure"
    cmd.Parameters.Add("Your Parameter Name", SqlDbType.VarChar).Value = expression
    cmd.Connection = con
    Using dr As IDataReader = cmd.ExecuteReader()
        If dr.Read() Then
        End If
    End Using
End Using