1
我有一個combobox
,我想用它從用戶選擇中選擇數據庫。我已經發現了大量關於用表值填充字段的信息,但是沒有關於他們可以使用哪個.dbo
的選擇。我猜可以使用相同的原則如下... 但我會假設(database =
)需要取出並取代了一些方法。 任何意見,將不勝感激通過組合框選擇數據庫
var connectionString = "server = (local); database = database; integrated security = true;"
string Sql = "select database...";
SqlConnection _con = new SqlConnection(connectionString);
_con.Open();
SqlCommand cmd = new SqlCommand(Sql, conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
combobox1.Items.Add(reader[0]);
}
因此,它越往下什麼SQL查詢我再發? 對不起,這個例子並沒有奏效,但我更傾向於猜測我的結局。 –
@JamesBurnieMcburnie什麼是您的數據庫?不是SQL Server嗎? –
事實上,對不起,它實際上在我的代碼中進一步發展,並沒有在正確的位置執行,導致它在向用戶顯示之前不填充。 立即工作。謝謝 –