Skip to content Skip to sidebar Skip to footer

Are There Ways To Add 2 Table When Using The Insert Statement In Query Builder?

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?

Solution 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

Solution 2:

Using con As System.Data.SqlClient.SqlConnection = New SqlConnection("YourConnection string")
    con.Open()
    Dim cmd AsNew SqlCommand()
    Dim expression AsString = "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() ThenEndIfEndUsingEndUsing

Post a Comment for "Are There Ways To Add 2 Table When Using The Insert Statement In Query Builder?"