Sql server 如何在vb.net中导入sql?

Sql server 如何在vb.net中导入sql?,sql-server,vb.net,Sql Server,Vb.net,我是说程序最上面的imports关键字。 我应该在里面打什么 Imports System.Data Imports System.Data.SqlClient 下面是一个如何与db对话的示例: Using cn As New SqlConnection("connection string here"), _ cmd As New SqlCommand("Sql statements here") cn.Open() Using rdr As SqlDataR

我是说程序最上面的imports关键字。 我应该在里面打什么

Imports System.Data
Imports System.Data.SqlClient
下面是一个如何与db对话的示例:

Using cn As New SqlConnection("connection string here"), _
      cmd As New SqlCommand("Sql statements here")

    cn.Open()

    Using rdr As SqlDataReader = cmd.ExecuteReader()
        While rdr.Read()
            ''# Do stuff with the data reader
        End While
    End Using
End Using
还有c#翻译,因为人们对评论感到好奇:

using (var cn = new SqlConnection("connection string here"))
using (var cmd = new SqlCommand("Sql statements here"))
{
    cn.Open();
    using (var rdr = cmd.ExecuteReader())
    {
        while (rdr.Read())
        {
            // Do stuff with the data reader
        }
    }
}
下面是一个如何与db对话的示例:

Using cn As New SqlConnection("connection string here"), _
      cmd As New SqlCommand("Sql statements here")

    cn.Open()

    Using rdr As SqlDataReader = cmd.ExecuteReader()
        While rdr.Read()
            ''# Do stuff with the data reader
        End While
    End Using
End Using
还有c#翻译,因为人们对评论感到好奇:

using (var cn = new SqlConnection("connection string here"))
using (var cmd = new SqlCommand("Sql statements here"))
{
    cn.Open();
    using (var rdr = cmd.ExecuteReader())
    {
        while (rdr.Read())
        {
            // Do stuff with the data reader
        }
    }
}
你的意思是:

Imports System.Data.SqlClient
你的意思是:

Imports System.Data.SqlClient

我想知道,如果你不能通过阅读文档或Intellisense找到正确的软件包名称,你打算如何使用软件包?我想知道,如果你不能通过阅读文档或Intellisense找到正确的软件包名称,你打算如何使用软件包?哇,我不知道在using语句中可以使用两个变量。这也会转化为C#吗?有点:C#确实允许这样做,但确切的语法有点不同。C#的工作原理是关于{}块的常规规则:如果只有一条语句,就不需要大括号。在C#中,您也可以在一个using指令中用逗号分隔多个对象,但是当您这样做时,它们必须是同一类型的,因此这通常效果更好。为了获得更多乐趣,请尝试使用
using()try\n{\n}\n catch(){}
哇,我没有意识到可以在using语句中使用两个变量。这也会转化为C#吗?有点:C#确实允许这样做,但确切的语法有点不同。C#的工作原理是关于{}块的常规规则:如果只有一条语句,就不需要大括号。您也可以在C#中的一个using指令中用逗号分隔多个对象,但当您这样做时,它们必须是同一类型的,因此这通常效果更好。为了获得更多乐趣,请尝试使用
using()try\n{\n}\n catch(){}