问题描述
海,
我需要使用Oledb Connection从sqlserver检索数据...因为使用此方法我们可以从任何来源获取数据..
但是我的代码显示错误..我不知道为什么..
Hai,
i need to retrive the Data from sqlserver using the Oledb Connection...because using this we can get data from any source..
But my code showing error.. i don''t know why..
using System.Data;
using System.Data.OleDb;
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
try{
OleDbConnection oConn = new OleDbConnection(@"Provider=SQLOLEDB;Data Source=ETG75\SQLEXPRESS;Initial Catalog=SampleDb;Integrated Security=True");
if (oConn.State != ConnectionState.Open)
{
oConn.Open();
}
}
catch(Exception ex)
{
}
}
}
该代码给出以下错误...
没有可用的错误消息,结果代码:DB_E_ERRORSOCCURRED(0x80040E21)."
将"Integrated Security = True"替换为"Trusted_connection = true"时
它给出类似用户venkat登录失败"之类的错误
但是我可以用sqlconnection连接...
请提供有关如何通过Oledb提供程序进行连接和打开的解决方案...
}
This Code giving the Following error...
"No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21)."
When replace the "Integrated Security=True " with "Trusted_connection=true "
it giving error like " Login failed for the user venkat"
But i can connect with sqlconnection...
Please provide the Solution for the How to Connect and Open through Oledb provider......
推荐答案
这篇关于在Ado.net中打开连接时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!