“System.Data.SqlClient.SqlException”類型的未經處理的異常在 System.Data.dll 中發生
其他信息: 用戶 'MicrosoftAccount\[email protected]' 登錄失敗。
//創建連接對象
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["partialConnectString"].ToString();
//建立命令對象
SqlCommand cmd = new SqlCommand("select l_number,l_type,workHours,exaWorkHours,l_unitPrice,unitPriceTerms,exaUnitPriceTerms from LCA where number=0", conn);
//創建適配器對象
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
//創建數據集
DataSet deptDataSet = new DataSet();
//填充數據集
adapter.Fill(deptDataSet, "lca");
//綁定數據
DataView dv = new DataView(deptDataSet.Tables["lca"]);
this.dgvLCA.DataSource = dv;
this.dgvLCA.Columns[0].HeaderText = "序號";
this.dgvLCA.Columns[1].HeaderText = "加工類型";
this.dgvLCA.Columns[2].HeaderText = "工時";
this.dgvLCA.Columns[3].HeaderText = "審核工時";
this.dgvLCA.Columns[4].HeaderText = "單價(元)";
this.dgvLCA.Columns[5].HeaderText = "單價項";
this.dgvLCA.Columns[6].HeaderText = "審核單價項";
app。config裡
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="partialConnectString"
connectionString="Data Source=.;Initial Catalog=NAVECODB; User ID=sa; Password=123456;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Integrated Security=false
你這個是用sa去連的。