在查询生成器中使用 INSERT 语句时是否有方法添加 2 个表?

发布于 2025-01-05 10:45:58 字数 53 浏览 4 评论 0原文

看来vb中的查询生成器只允许1个表使用INSERT语句,那么有什么方法可以添加超过1个表吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

_失温 2025-01-12 10:45:58

您应该能够将它们全部包装到一个命令调用中。这是我认为您正在寻找的示例。

如何从 vb.net 插入两个表

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

残花月 2025-01-12 10:45:58
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文