[英]How to select all the tables from SQL Server is connected remotely via the internet using C #?
I have a question like this! 我有这样的问题!
How to select all the tables from SQL Server is connected remotely via the internet from another machine using C #? 如何从使用C#通过另一台计算机通过Internet远程连接的SQL Server中选择所有表?
If possible, select all the fields in a database table any of that? 如果可能,选择数据库表中的所有字段吗?
//connectionstring will have all your SqlServer name user id and password // 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.