我有Formselectserver
其中從組合框中獲取SQL Server的名稱。我也有form2
哪裏是主要的形式。在連接字符串中設置SQL Server名稱不起作用
我發送combobox.selectedvalue
到form2中的連接字符串,但不起作用。
我想讓用戶在網絡中選擇一個SQL Server並連接到它。
Formselectserver objfrmserver = new Formselectserver();
private const string strconnection =
@"server='" + objfrmserver.cmbshowallsqlserver.SelectedValue +
"';database = anfd; Integrated Security = SSPI";
錯誤是:
一個對象引用是所必需的非靜態字段, 方法,或屬性 'exportdatafromholoo.Form1.objfrmserver'
錯誤沒有解決和錯誤bacome更多 – anfd 2013-05-01 14:51:16
我用一個例子更新了我的答案。 – 2013-05-01 14:53:51
如何使用SqlConnection objconnection = new SqlConnection(strconnection); – anfd 2013-05-01 15:02:20