“System.Data.SqlClient.SqlException”类型的未经处理的异常在 System.Data.dll 中发生
其他信息: 用户 'MicrosoftAccount\hong34210@hotmail.com' 登录失败。
//创建连接对象
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去连的。