[英]navigate and print sql database
我正在編寫一個應用程序,允許您在db中查看和打開表。 我想通過用戶輸入一個數字(列表索引)來打開表格,並打印出所選表格中的內容。 我試過了:
using (NorthwindDataContext db = new NorthwindDataContext())
{
List<System.Data.Linq.Mapping.MetaTable> tables = db.Mapping.GetTables().ToList();
for (int i = 0; i < tables.Count(); i++)
{
var s = tables[i].TableName;
Console.WriteLine(i+". "+s);
}
Console.WriteLine("Choose index to open");
string str = Console.ReadLine();
int number = Convert.ToInt32(str);
} }
我需要一個基於索引選擇正確表的查詢。
使用相同的方式讀取它(tables [index]):
"SELECT * from " + tables[number].TableName
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.