OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.xls)|*.xls";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = openFileDialog1.FileName;
}
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + strPath + "';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(textBox1.Text);
问题,提示路径不对,C:\f\f.xls
正确应该是C:\\f\\f.xls
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.xls)|*.xls";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = openFileDialog1.FileName;
}
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + strPath + "';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(textBox1.Text);
问题,提示路径不对,C:\f\f.xls
正确应该是C:\\f\\f.xls
解决方案 »
- 关于C1FlexGrid的SubTotal函数
- C#多线程基础求救
- WebForm中有沒有C#消息框、提示框啊??
- 现在一个主窗口里,有多个MDI子窗口,怎么实现联动性。。
- js中parseInt(string,36)这样的函数在C#中有吗?如何将字符转换成36进制呢?
- 请各位老大帮忙啊,急急急急急急急急急急!!!
- 一定近来看看俺的创意!!!!
- VC#与Com组件...对面的高手看过来!!(解决了可以再加分)
- C#初学者,希望大家来提点儿好的学习方法!谢谢
- 请教Graphics如何实现windows GDI函数PatBlt()的功能
- TreeView.SelectedNode怎么没有Depth这个属性啊。(WinForm)
- 综合类,前沿技术问题(2005+2005)
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + textBox1.Text + "';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(mystring );
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + strPath + "';Extended Properties=Excel 8.0";Data Source = 后加“'”做什么的?这样试下string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source=" + strPath + ";Extended Properties=Excel 8.0";PS:strPath是什么,你的代码并没有给出