oledb插入问题

扫码查看
本文介绍了oledb插入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是Simone,在C#中使用oledb时遇到问题:

我必须在Excel表格的新行中从文本框中插入值.
这是代码:

Hi,

I am Simone and have a problem using oledb in c#:

I have to insert values from textboxes in a new row in a excel table.
here is the code:

private void scriviexcel(string filexcel)//fileexcel="c:\\prova.xls";
        {
            string scheda="table1";
            OleDbConnection conn = new OleDbConnection();
            OleDbCommand command = new OleDbCommand();
            conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filexcel + ";Extended Properties=Excel 8.0;");//HDR=YES;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0""";
            string datao = DateTime.Now.ToString();
            datao=datao.Substring(0, 10);
            //cut the time from DateTime so datao="02/11/2011";
            string pro = "INSERT INTO " + scheda + "(nome,indirizzo,telefono,difetto,data) VALUES(''{" + textBox1.Text + "}'',''{" + textBox2.Text + "}'',''{" + textBox3.Text + "}'',''{" + textBox4.Text + "}'',''{"+datao+"}'')";
            command = new OleDbCommand
            (
            pro,conn
            );
            command.Connection.Open();
            command.ExecuteNonQuery();
            command.Connection.Close();
            conn.Close();
        }


这是错误:
"Jet数据库引擎找不到对象"table1".请确保对象存在,并且名称和路径名正确."

我需要安装Microsoft Office吗?

有人可以帮我吗?

谢谢


and this is the error:
"The Jet database engine could not find the object ''table1''. Make sure the object exists and the name and path name correctly."

I need to have microsoft office installed ?

can anyone help me?

Thanks

推荐答案




这篇关于oledb插入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 14:44
查看更多