如果收到错误的数据库错误消息是什么意思? [英] What does it mean if one gets the folliwing database error message?

查看:150
本文介绍了如果收到错误的数据库错误消息是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到我创建并设置了密码的sql server ce数据库.我能够 co <​​/strike> 连接到 d 使用 d the 数据库使用Visual Studio成功分配了密码,但是当我尝试使用代码连接到数据库时,我得到了 d the ffg 以下错误消息:

I was trying to connect to an sql server ce database that I had created and passworded.I was able co to connect to d the database with d the assigned password successfully using visual studio but when I tried to connect to it using code I get d the ffg following error message:

Description: Provider could not set datasource,password, or username<br />
Message:IDispatch error #3105







#include "stdafx.h"
#include<Ole2.h>
#include<tchar.h>
#include<strsafe.h>
#import "C:\Program Files\Common Files\System\Ado\msado15.dll" no_namespace rename("EOF","EndOfFile")

int main()
{
	_ConnectionPtr Conn = NULL;
	_CommandPtr Cmd = NULL;

	::CoInitializeEx(NULL,COINIT_MULTITHREADED);
	try
	{
		TCHAR szConnString[] = _T("Provider='Microsoft.SQLSERVER.CE.OLEDB.3.5';Persist Security Info='FALSE';Data Source='D:\\Projects\\Projects\\Maga\\MagaMy\\MyDatabase#2.sdf';");
		
		Conn.CreateInstance(__uuidof(Connection));

		Conn->Open(_bstr_t(szConnString),_bstr_t(_T("")),_bstr_t(_T("1234567890")),adConnectUnspecified);

		Conn->Close();
		
	}
	catch(_com_error e)
	{
		TCHAR szString[1000];
		_bstr_t Error = e.Description();
		TCHAR *szDescription = (TCHAR *)Error;
		const TCHAR * szError = e.ErrorMessage();
		StringCbPrintf(szString,sizeof(szString),_T("Description : %s ; Message : %s"),szDescription,szError);
		//IErrorInfo *IError = e.ErrorInfo();
		MessageBox(NULL,szString,_T("Class Creation Error"),MB_OK);
		if(Conn)
		{
			Conn->Close();
		}
	}
	
	::CoUninitialize();
	
	return 1;
}

推荐答案

您是否将提供程序设置为锥孔字符串?
如果没有,那么请尝试这样..

did you set the provider to the conectionString??
if not then try like this..

"Provider=SQLOLEDB;Data Source=.\\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=SSPI;Persist Security Info=False"


使用Sql Server CE数据库时,通常不必在用户中使用用户信息连接字符串.这是因为它在进程中运行.因此,尝试将连接字符串修改为
When using Sql Server CE database, typically you don''t have to use user information in your connection string. This is because it runs in-process. So try modifying your connection string as
TCHAR szConnString[] = _T("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=D:\\Projects\\Projects\\Maga\\MagaMy\\MyDatabase#2.sdf");


这篇关于如果收到错误的数据库错误消息是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆