[英]An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB
I am creating an application which uses access file from shared network.The application works fine when the access file is placed local.But when I placed it in shared path and trying to connect.It is throwing an exception." An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB Here is my code: 我正在创建一个使用共享网络访问文件的应用程序。将访问文件放置在本地时,该应用程序工作正常。但是,当我将其放置在共享路径中并尝试连接时,它会引发异常。” OLE DB Provider是未在ConnectionString中指定。'Provider = SQLOLEDB这是我的代码:
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\server\\MyFirstProject\\SampleDB2.accdb";
using (OleDbConnection con = new OleDbConnection(connectionString))
{
string command = "INSERT INTO emp_status(emp_id,hours,feeded_on,comments)";
command += "VALUES(@emp_id,@hours,@feeded_on,@comments)";
Could anyone help me how to resolve this issue and Am I missing something? 谁能帮我解决这个问题,我有什么遗漏吗? I am using OLEB as a datasourse and Access 2013 Any Suggestions or explanations would definitely helps me.
我正在使用OLEB作为数据源和Access2013。任何建议或解释都一定会对我有所帮助。
Thanks in advance!! 提前致谢!!
You need to escape the leading double slash as well... 您还需要逃脱领先的双斜线...
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\\\server\\MyFirstProject\\SampleDB2.accdb";
I haven't got anything to check this on here, but I'm fairly sure this is your answer. 我没有什么可以在这里检查的,但是我很确定这是您的答案。 Also, watch out for reserved words, Eg "hours" might be one in which case it should be [hours].
另外,请注意保留字,例如“ hours”可能是一个“ hours”。
Also, you haven't specifically included adding the parameter values in your question. 另外,您还没有明确地在问题中添加参数值。 I assume you are doing it but if not then see my coding example here...
我认为您正在这样做,但是如果没有,请在此处查看我的编码示例...
VB 2010 error (INSERT INTO) syntax error VB 2010错误(INSERT INTO)语法错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.