簡體   English   中英

如何從使用C#通過Internet遠程連接的SQL Server中選擇所有表?

[英]How to select all the tables from SQL Server is connected remotely via the internet using C #?

我有這樣的問題!

如何從使用C#通過另一台計算機通過Internet遠程連接的SQL Server中選擇所有表?

如果可能,選擇數據庫表中的所有字段嗎?

// connectionstring將具有您所有的SqlServer名稱用戶名和密碼

private static void ReadOrderData(string connectionString)
{
    string queryString =
        "SELECT OrderID, CustomerID FROM dbo.Orders;";

    using (SqlConnection connection =
               new SqlConnection(connectionString))
    {
        SqlCommand command =
            new SqlCommand(queryString, connection);
        connection.Open();

        SqlDataReader reader = command.ExecuteReader();

        // Call Read before accessing data.
        while (reader.Read())
        {
            Console.WriteLine(String.Format("{0}, {1}",
                reader[0], reader[1]));
        }

        // Call Close when done reading.
        reader.Close();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM