我一直在做一个 C# 工程, 我浏览并浏览一个 Excel 文件到网格视图中。 但是, 有一个错误信息, 我无法理解 。 有人能帮我一下吗 。
这是我用的代码:
private void buttonUpload_Click(object sender, EventArgs e)
{
string connectionString = String.Format(@"Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", textBoxFileName.Text);
string query = String.Format("select * from [{0}$]", "Sheet1");
SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connectionString);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
dataGridView1.DataSource = dataSet.Tables[0];
}
这是错误消息 :
"A network-related or instance-specific error occurred while establishing
a connection to SQL Server. The server was not found or was not accessible.
Verify that the instance name is correct and that SQL Server is configured
to allow remote connections.
(provider: SQL Network Interfaces,
error: 26 - Error Locating Server/Instance Specified)."